提交 64fe5e59 编写于 作者: M Manish Vasani

Do not expose operation nodes for BoundRangeVariables in C# query expression

These nodes contain the bound parameter reference to the underlying lambda parameter, which is now exposed.
Fixes #23079
上级 c6503323
......@@ -43,14 +43,14 @@ protected override BoundExpression BindRangeVariable(SimpleNameSyntax node, Rang
// the range variable maps directly to a use of the parameter of that name
var value = base.parameterMap[qv.Name];
Debug.Assert(value.Count == 1);
translation = new BoundParameter(node, value.Single()) { WasCompilerGenerated = true };
translation = new BoundParameter(node, value.Single());
}
else
{
// if the query variable map for this variable is non empty, we always start with the current
// lambda's first parameter, which is a transparent identifier.
Debug.Assert(base.lambdaSymbol.Parameters[0].Name.StartsWith(transparentIdentifierPrefix, StringComparison.Ordinal));
translation = new BoundParameter(node, base.lambdaSymbol.Parameters[0]) { WasCompilerGenerated = true };
translation = new BoundParameter(node, base.lambdaSymbol.Parameters[0]);
for (int i = path.Length - 1; i >= 0; i--)
{
var nextField = path[i];
......
......@@ -239,6 +239,8 @@ private IOperation CreateInternal(BoundNode boundNode)
return CreateBoundQueryClauseOperation((BoundQueryClause)boundNode);
case BoundKind.DelegateCreationExpression:
return CreateBoundDelegateCreationExpressionOperation((BoundDelegateCreationExpression)boundNode);
case BoundKind.RangeVariable:
return Create(((BoundRangeVariable)boundNode).Value);
default:
Optional<object> constantValue = ConvertToOptional((boundNode as BoundExpression)?.ConstantValue);
bool isImplicit = boundNode.WasCompilerGenerated;
......
......@@ -1929,7 +1929,7 @@ static void Main(string[] args)
IArgumentOperation (ArgumentKind.Explicit, Matching Parameter: z) (OperationKind.Argument, Type: null, IsImplicit) (Syntax: 'x.ToString()')
IInvocationOperation (virtual System.String System.Char.ToString()) (OperationKind.Invocation, Type: System.String) (Syntax: 'x.ToString()')
Instance Receiver:
IOperation: (OperationKind.None, Type: null) (Syntax: 'x')
IParameterReferenceOperation: x (OperationKind.ParameterReference, Type: System.Char) (Syntax: 'x')
Arguments(0)
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
......@@ -1946,7 +1946,9 @@ static void Main(string[] args)
IBlockOperation (1 statements) (OperationKind.Block, Type: null, IsImplicit) (Syntax: 'z')
IReturnOperation (OperationKind.Return, Type: null, IsImplicit) (Syntax: 'z')
ReturnedValue:
IOperation: (OperationKind.None, Type: null) (Syntax: 'z')
IPropertyReferenceOperation: System.String <anonymous type: System.Char x, System.String z>.z { get; } (OperationKind.PropertyReference, Type: System.String, IsImplicit) (Syntax: 'z')
Instance Receiver:
IParameterReferenceOperation: <>h__TransparentIdentifier0 (OperationKind.ParameterReference, Type: <anonymous type: System.Char x, System.String z>) (Syntax: 'z')
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
......@@ -1958,7 +1960,7 @@ static void Main(string[] args)
IBlockOperation (1 statements) (OperationKind.Block, Type: null, IsImplicit) (Syntax: 'w')
IReturnOperation (OperationKind.Return, Type: null, IsImplicit) (Syntax: 'w')
ReturnedValue:
IOperation: (OperationKind.None, Type: null) (Syntax: 'w')
IParameterReferenceOperation: w (OperationKind.ParameterReference, Type: System.String) (Syntax: 'w')
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Initializer:
......@@ -2091,7 +2093,7 @@ private static IEnumerable<string> fun()
IArgumentOperation (ArgumentKind.Explicit, Matching Parameter: z) (OperationKind.Argument, Type: null, IsImplicit) (Syntax: 'x.ToString()')
IInvocationOperation (virtual System.String System.Char.ToString()) (OperationKind.Invocation, Type: System.String) (Syntax: 'x.ToString()')
Instance Receiver:
IOperation: (OperationKind.None, Type: null) (Syntax: 'x')
IParameterReferenceOperation: x (OperationKind.ParameterReference, Type: System.Char) (Syntax: 'x')
Arguments(0)
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
......@@ -2108,7 +2110,9 @@ private static IEnumerable<string> fun()
IBlockOperation (1 statements) (OperationKind.Block, Type: null, IsImplicit) (Syntax: 'z')
IReturnOperation (OperationKind.Return, Type: null, IsImplicit) (Syntax: 'z')
ReturnedValue:
IOperation: (OperationKind.None, Type: null) (Syntax: 'z')
IPropertyReferenceOperation: System.String <anonymous type: System.Char x, System.String z>.z { get; } (OperationKind.PropertyReference, Type: System.String, IsImplicit) (Syntax: 'z')
Instance Receiver:
IParameterReferenceOperation: <>h__TransparentIdentifier0 (OperationKind.ParameterReference, Type: <anonymous type: System.Char x, System.String z>) (Syntax: 'z')
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
......@@ -2120,7 +2124,7 @@ private static IEnumerable<string> fun()
IBlockOperation (1 statements) (OperationKind.Block, Type: null, IsImplicit) (Syntax: 'w')
IReturnOperation (OperationKind.Return, Type: null, IsImplicit) (Syntax: 'w')
ReturnedValue:
IOperation: (OperationKind.None, Type: null) (Syntax: 'w')
IParameterReferenceOperation: w (OperationKind.ParameterReference, Type: System.String) (Syntax: 'w')
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
";
......
......@@ -175,7 +175,7 @@ public void M(List<Customer> customers)
ReturnedValue:
IPropertyReferenceOperation: System.String Customer.Name { get; set; } (OperationKind.PropertyReference, Type: System.String) (Syntax: 'cust.Name')
Instance Receiver:
IOperation: (OperationKind.None, Type: null) (Syntax: 'cust')
IParameterReferenceOperation: cust (OperationKind.ParameterReference, Type: Customer) (Syntax: 'cust')
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
";
......
......@@ -443,7 +443,7 @@ static object M1(int[] a)
ReturnedValue:
IUnaryOperation (UnaryOperatorKind.Minus) (OperationKind.UnaryOperator, Type: System.Int32) (Syntax: '-r')
Operand:
IOperation: (OperationKind.None, Type: null) (Syntax: 'r')
IParameterReferenceOperation: r (OperationKind.ParameterReference, Type: System.Int32) (Syntax: 'r')
InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册