Skip to content

Instantly share code, notes, and snippets.

@controlflow
Last active November 16, 2020 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save controlflow/9c5b4b58e6b3e89abb3755ccdd6e55f2 to your computer and use it in GitHub Desktop.
Save controlflow/9c5b4b58e6b3e89abb3755ccdd6e55f2 to your computer and use it in GitHub Desktop.
if (pattern is IPatternWithDesignation withDesignation)
{
var existingDesignation = withDesignation.Designation;
if (existingDesignation != null && !(existingDesignation is IDiscardDesignation)) return false;
}
// after "Merge sequential patterns"
if (pattern is IPatternWithDesignation withDesignation)
{
var existingDesignation = withDesignation.Designation;
if (existingDesignation is { } and not IDiscardDesignation) return false;
}
// after "Replace `and` with `or`"
if (pattern is IPatternWithDesignation withDesignation)
{
var existingDesignation = withDesignation.Designation;
if (existingDesignation is not (null or IDiscardDesignation)) return false;
}
// inline variable, merge ifs, merge sequential patterns into recursive
if (pattern is IPatternWithDesignation { Designation: not (null or IDiscardDesignation) })
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment