diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs b/src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs index af6ff94026f95ac35786488f2e45d5526f5592b1..8943a52c1e95ea36e90cb9f3cf0eb0fe3751a363 100644 --- a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs +++ b/src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs @@ -1366,9 +1366,12 @@ private IEnumerable InferTypeInIfStatement(IfStatementSyntax private IEnumerable GetPatternTypes(PatternSyntax pattern) { - return pattern.TypeSwitch( - (DeclarationPatternSyntax declarationPattern) => GetTypes(declarationPattern.Type), - (ConstantPatternSyntax constantPattern) => GetTypes(constantPattern.Expression)); + switch (pattern) + { + case DeclarationPatternSyntax declarationPattern: return GetTypes(declarationPattern.Type); + case ConstantPatternSyntax constantPattern: return GetTypes(constantPattern.Expression); + default: return null; + } } private IEnumerable InferTypeInLockStatement(LockStatementSyntax lockStatement, SyntaxToken? previousToken = null) @@ -1740,9 +1743,12 @@ private IEnumerable InferTypeInYieldStatement(YieldStatementS var memberSymbol = GetDeclaredMemberSymbolFromOriginalSemanticModel(SemanticModel, yieldStatement.GetAncestorOrThis()); - var memberType = memberSymbol.TypeSwitch( - (IMethodSymbol method) => method.ReturnType, - (IPropertySymbol property) => property.Type); + var memberType = (ITypeSymbol)null; + switch (memberSymbol) + { + case IMethodSymbol method: memberType = method.ReturnType; break; + case IPropertySymbol property: memberType = property.Type; break; + } if (memberType is INamedTypeSymbol) {