提交 d570bc79 编写于 作者: M Manish Vasani

Ensure that IOperations nodes within an IsPatternExpression are part of the Operation tree

Fixes #19790
上级 ff80e150
......@@ -2820,6 +2820,8 @@ public override void Accept(OperationVisitor visitor)
// TODO: implement IOperation for pattern-matching constructs (https://github.com/dotnet/roslyn/issues/8699)
protected override OperationKind ExpressionKind => OperationKind.None;
protected override ImmutableArray<IOperation> Children => ImmutableArray.Create<IOperation>(this.Expression, this.Pattern);
}
/// <summary>
......
......@@ -827,5 +827,28 @@ static void M(int x, __arglist)
VerifyOperationTreeAndDiagnosticsForTest<InvocationExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
[Fact, WorkItem(19790, "https://github.com/dotnet/roslyn/issues/19790")]
public void ParameterReference_IsPatternExpression()
{
string source = @"
class Class1
{
public void Method1(object x)
{
if (/*<bind>*/x is int y/*</bind>*/) { }
}
}
";
string expectedOperationTree = @"
IOperation: (OperationKind.None) (Syntax: 'x is int y')
Children(2): IParameterReferenceExpression: x (OperationKind.ParameterReferenceExpression, Type: System.Object) (Syntax: 'x')
IOperation: (OperationKind.None) (Syntax: 'int y')
Children(1): ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'int y')
";
var expectedDiagnostics = DiagnosticDescription.None;
VerifyOperationTreeAndDiagnosticsForTest<IsPatternExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册