提交 6cc8247b 编写于 作者: N Neal Gafter

Merge from rpatterns4

......@@ -34,13 +34,13 @@ internal override BoundSwitchExpressionArm BindSwitchExpressionArm(SwitchExpress
{
Debug.Assert(node == _arm);
var caseBinder = this.GetBinder(node);
var hasErrors = _switchExpressionBinder.SwitchGoverningExpression.HasErrors;
var hasErrors = _switchExpressionBinder.SwitchGoverningType.IsErrorType();
var locals = _armScopeBinder.Locals;
var pattern = caseBinder.BindPattern(node.Pattern, _switchExpressionBinder.SwitchGoverningType, hasErrors, diagnostics);
var guard = node.WhenClause != null
? caseBinder.BindBooleanExpression((ExpressionSyntax)node.WhenClause.Condition, diagnostics)
? caseBinder.BindBooleanExpression(node.WhenClause.Condition, diagnostics)
: null;
var result = caseBinder.BindValue((ExpressionSyntax)node.Expression, diagnostics, BindValueKind.RValue);
var result = caseBinder.BindValue(node.Expression, diagnostics, BindValueKind.RValue);
return new BoundSwitchExpressionArm(node, locals, pattern, guard, result, hasErrors);
}
}
......
......@@ -45,7 +45,7 @@ internal override BoundExpression BindSwitchExpressionCore(SwitchExpressionSynta
/// </summary>
private TypeSymbol InferResultType(ImmutableArray<BoundSwitchExpressionArm> switchCases, DiagnosticBag diagnostics)
{
var seenTypes = new HashSet<TypeSymbol>();
var seenTypes = PooledHashSet<TypeSymbol>.GetInstance();
var typesInOrder = ArrayBuilder<TypeSymbol>.GetInstance();
foreach (var @case in switchCases)
{
......@@ -65,6 +65,7 @@ private TypeSymbol InferResultType(ImmutableArray<BoundSwitchExpressionArm> swit
commonType = CreateErrorType();
}
seenTypes.Free();
return commonType;
}
......
......@@ -454,7 +454,7 @@ bool looksLikeCast()
{
// There is an ambiguity between a deconstruction pattern `(` pattern `)`
// and a constant expression pattern that happens to be parenthesized.
// Per 2017-11-20 LDM we treat such syntax as a parenthseized expression always.
// Per 2017-11-20 LDM we treat such syntax as a parenthesized expression always.
return _syntaxFactory.ConstantPattern(_syntaxFactory.ParenthesizedExpression(openParenToken, cp.Expression, closeParenToken));
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册