Skip to content

Instantly share code, notes, and snippets.

@controlflow
Created February 12, 2017 15:43
Show Gist options
  • Save controlflow/c2b62254a57cff8c44403191db881869 to your computer and use it in GitHub Desktop.
Save controlflow/c2b62254a57cff8c44403191db881869 to your computer and use it in GitHub Desktop.
var pattern = Pattern;
var constantPattern = pattern as IConstantPattern;
if (constantPattern != null)
{
return IsTypeFromConstantPattern(constantPattern);
}
var declarationPattern = pattern as IDeclarationPattern;
if (declarationPattern != null)
{
var typeUsage = declarationPattern.TypeUsage;
if (typeUsage != null)
{
return CSharpTypeFactory.CreateType(typeUsage);
}
}
return TypeFactory.CreateUnknownType(this);
switch (Pattern)
{
case IConstantPattern constantPattern:
return IsTypeFromConstantPattern(constantPattern);
case IDeclarationPattern declarationPattern when declarationPattern.TypeUsage is ITypeUsage typeUsage:
return CSharpTypeFactory.CreateType(typeUsage);
default:
return TypeFactory.CreateUnknownType(this);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment