提交 e9f73e3f 编写于 作者: S Scott Caldwell

Add when clause case to the TypeInferrer

上级 12f3cd17
......@@ -168,6 +168,7 @@ private IEnumerable<TypeInferenceInfo> GetTypesSimple(ExpressionSyntax expressio
case ThrowExpressionSyntax throwExpression: return InferTypeInThrowExpression(throwExpression);
case ThrowStatementSyntax throwStatement: return InferTypeInThrowStatement(throwStatement);
case UsingStatementSyntax usingStatement: return InferTypeInUsingStatement(usingStatement);
case WhenClauseSyntax whenClause: return InferTypeInWhenClause(whenClause);
case WhileStatementSyntax whileStatement: return InferTypeInWhileStatement(whileStatement);
case YieldStatementSyntax yieldStatement: return InferTypeInYieldStatement(yieldStatement);
default: return SpecializedCollections.EmptyEnumerable<TypeInferenceInfo>();
......@@ -238,6 +239,7 @@ protected override IEnumerable<TypeInferenceInfo> InferTypesWorker_DoNotCallDire
case SwitchStatementSyntax switchStatement: return InferTypeInSwitchStatement(switchStatement, token);
case ThrowStatementSyntax throwStatement: return InferTypeInThrowStatement(throwStatement, token);
case UsingStatementSyntax usingStatement: return InferTypeInUsingStatement(usingStatement, token);
case WhenClauseSyntax whenClause: return InferTypeInWhenClause(whenClause, token);
case WhileStatementSyntax whileStatement: return InferTypeInWhileStatement(whileStatement, token);
case YieldStatementSyntax yieldStatement: return InferTypeInYieldStatement(yieldStatement, token);
default: return SpecializedCollections.EmptyEnumerable<TypeInferenceInfo>();
......@@ -2150,6 +2152,17 @@ private IEnumerable<TypeInferenceInfo> InferTypeInVariableComponentAssignment(Ex
elementNamesBuilder.Add(null);
}
private IEnumerable<TypeInferenceInfo> InferTypeInWhenClause(WhenClauseSyntax whenClause, SyntaxToken? previousToken = null)
{
// If we have a position, we have to be after the "when"
if (previousToken.HasValue && previousToken.Value != whenClause.WhenKeyword)
{
return SpecializedCollections.EmptyEnumerable<TypeInferenceInfo>();
}
return SpecializedCollections.SingletonEnumerable(new TypeInferenceInfo(Compilation.GetSpecialType(SpecialType.System_Boolean)));
}
private IEnumerable<TypeInferenceInfo> InferTypeInWhileStatement(WhileStatementSyntax whileStatement, SyntaxToken? previousToken = null)
{
// If we're position based, then we have to be after the "while("
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册