提交 d27e87e2 编写于 作者: N Neal Gafter

Changes per code review on previous PR in pattern-matching branch.

上级 c7673f60
......@@ -2603,7 +2603,7 @@ private BoundExpression BindIsOperator(BinaryExpressionSyntax node, DiagnosticBa
bool wasExpression;
var tempBag2 = DiagnosticBag.GetInstance();
var boundConstantPattern = BindConstantPattern(
node, operand, operand.Type, node.Right, node.Right.HasErrors, tempBag2, out wasExpression, wasSwitch: false);
node, operand, operand.Type, node.Right, node.Right.HasErrors, tempBag2, out wasExpression, wasSwitchCase: false);
if (wasExpression)
{
tempBag.Free();
......
......@@ -26,7 +26,7 @@ private BoundExpression BindIsPatternExpression(IsPatternExpressionSyntax node,
TypeSymbol operandType,
bool hasErrors,
DiagnosticBag diagnostics,
bool wasSwitch = false)
bool wasSwitchCase = false)
{
switch (node.Kind())
{
......@@ -36,7 +36,7 @@ private BoundExpression BindIsPatternExpression(IsPatternExpressionSyntax node,
case SyntaxKind.ConstantPattern:
return BindConstantPattern(
(ConstantPatternSyntax)node, operand, operandType, hasErrors, diagnostics, wasSwitch);
(ConstantPatternSyntax)node, operand, operandType, hasErrors, diagnostics, wasSwitchCase);
case SyntaxKind.PropertyPattern:
return BindPropertyPattern(
......@@ -524,10 +524,10 @@ private bool ApplicableOperatorIs(MethodSymbol candidate, CSharpSyntaxNode node,
TypeSymbol operandType,
bool hasErrors,
DiagnosticBag diagnostics,
bool wasSwitch = false)
bool wasSwitchCase)
{
bool wasExpression;
return BindConstantPattern(node, operand, operandType, node.Expression, hasErrors, diagnostics, out wasExpression, wasSwitch);
return BindConstantPattern(node, operand, operandType, node.Expression, hasErrors, diagnostics, out wasExpression, wasSwitchCase);
}
internal BoundPattern BindConstantPattern(
......@@ -538,7 +538,7 @@ private bool ApplicableOperatorIs(MethodSymbol candidate, CSharpSyntaxNode node,
bool hasErrors,
DiagnosticBag diagnostics,
out bool wasExpression,
bool wasSwitch)
bool wasSwitchCase)
{
var expression = BindValue(right, diagnostics, BindValueKind.RValue);
wasExpression = expression.Type?.IsErrorType() != true;
......
......@@ -70,8 +70,9 @@ private static BoundPatternSwitchLabel BindPatternSwitchSectionLabel(Binder sect
case SyntaxKind.CasePatternSwitchLabel:
{
var matchLabelSyntax = (CasePatternSwitchLabelSyntax)node;
return new BoundPatternSwitchLabel(node,
sectionBinder.BindPattern(matchLabelSyntax.Pattern, boundSwitchExpression, boundSwitchExpression.Type, node.HasErrors, diagnostics, wasSwitch: true),
var pattern = sectionBinder.BindPattern(
matchLabelSyntax.Pattern, boundSwitchExpression, boundSwitchExpression.Type, node.HasErrors, diagnostics, wasSwitchCase: true);
return new BoundPatternSwitchLabel(node, pattern,
matchLabelSyntax.WhenClause != null ? sectionBinder.BindBooleanExpression(matchLabelSyntax.WhenClause.Condition, diagnostics) : null, node.HasErrors);
}
......@@ -79,7 +80,8 @@ private static BoundPatternSwitchLabel BindPatternSwitchSectionLabel(Binder sect
{
var caseLabelSyntax = (CaseSwitchLabelSyntax)node;
bool wasExpression;
var pattern = sectionBinder.BindConstantPattern(node, boundSwitchExpression, boundSwitchExpression.Type, caseLabelSyntax.Value, node.HasErrors, diagnostics, out wasExpression, wasSwitch: true);
var pattern = sectionBinder.BindConstantPattern(
node, boundSwitchExpression, boundSwitchExpression.Type, caseLabelSyntax.Value, node.HasErrors, diagnostics, out wasExpression, wasSwitchCase: true);
return new BoundPatternSwitchLabel(node, pattern, null, node.HasErrors);
}
......
......@@ -15299,8 +15299,8 @@ public static void Main(string[] args)
// case typeof(string[]):
Diagnostic(ErrorCode.ERR_ConstantExpected, "typeof(string[])").WithLocation(12, 18)
);
// If we decide to support switching on System.Type, the following line would be appropriate.
// CompileAndVerify(compilation, expectedOutput: @"string[]");
// If we support switching on System.Type as proposed, the expectation would be
// something like CompileAndVerify(compilation, expectedOutput: @"string[]");
}
[Fact, WorkItem(10364, "https://github.com/dotnet/roslyn/issues/10364")]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册