@@ -14797,5 +14797,80 @@ public class C<T> { }
14797
14797
// public static void C() { }
14798
14798
Diagnostic ( ErrorCode . ERR_MemberNameSameAsExtendedType , "C" ) . WithArguments ( "C" ) . WithLocation ( 5 , 28 ) ) ;
14799
14799
}
14800
+
14801
+ [ Fact ]
14802
+ public void ExtractCastInvocation_01 ( )
14803
+ {
14804
+ var src = """
14805
+ _ = /*<bind>*/ from int x in new C<int>()
14806
+ from int y in new C<int>()
14807
+ select x.ToString() + y.ToString() /*</bind>*/;
14808
+
14809
+ static class E
14810
+ {
14811
+ extension(C<int> source)
14812
+ {
14813
+ public C<string> SelectMany(System.Func<int, C<int>> collectionSelector, System.Func<int, int, string> resultSelector) => throw null;
14814
+ public C<T> Cast<T>() => throw null;
14815
+ }
14816
+ }
14817
+
14818
+ class C<T> { }
14819
+ """ ;
14820
+ var comp = CreateCompilation ( src ) ;
14821
+ comp . VerifyEmitDiagnostics ( ) ;
14822
+
14823
+ var expectedOperationTree = """
14824
+ ITranslatedQueryOperation (OperationKind.TranslatedQuery, Type: C<System.String>) (Syntax: 'from int x ... .ToString()')
14825
+ Expression:
14826
+ IInvocationOperation ( C<System.String> E.<>E__0.SelectMany(System.Func<System.Int32, C<System.Int32>> collectionSelector, System.Func<System.Int32, System.Int32, System.String> resultSelector)) (OperationKind.Invocation, Type: C<System.String>, IsImplicit) (Syntax: 'from int y ... ew C<int>()')
14827
+ Instance Receiver:
14828
+ IInvocationOperation ( C<System.Int32> E.<>E__0.Cast<System.Int32>()) (OperationKind.Invocation, Type: C<System.Int32>, IsImplicit) (Syntax: 'from int x ... ew C<int>()')
14829
+ Instance Receiver:
14830
+ IObjectCreationOperation (Constructor: C<System.Int32>..ctor()) (OperationKind.ObjectCreation, Type: C<System.Int32>) (Syntax: 'new C<int>()')
14831
+ Arguments(0)
14832
+ Initializer:
14833
+ null
14834
+ Arguments(0)
14835
+ Arguments(2):
14836
+ IArgumentOperation (ArgumentKind.Explicit, Matching Parameter: collectionSelector) (OperationKind.Argument, Type: null, IsImplicit) (Syntax: 'new C<int>()')
14837
+ IDelegateCreationOperation (OperationKind.DelegateCreation, Type: System.Func<System.Int32, C<System.Int32>>, IsImplicit) (Syntax: 'new C<int>()')
14838
+ Target:
14839
+ IAnonymousFunctionOperation (Symbol: lambda expression) (OperationKind.AnonymousFunction, Type: null, IsImplicit) (Syntax: 'new C<int>()')
14840
+ IBlockOperation (1 statements) (OperationKind.Block, Type: null, IsImplicit) (Syntax: 'new C<int>()')
14841
+ IReturnOperation (OperationKind.Return, Type: null, IsImplicit) (Syntax: 'new C<int>()')
14842
+ ReturnedValue:
14843
+ IInvocationOperation ( C<System.Int32> E.<>E__0.Cast<System.Int32>()) (OperationKind.Invocation, Type: C<System.Int32>, IsImplicit) (Syntax: 'new C<int>()')
14844
+ Instance Receiver:
14845
+ IObjectCreationOperation (Constructor: C<System.Int32>..ctor()) (OperationKind.ObjectCreation, Type: C<System.Int32>) (Syntax: 'new C<int>()')
14846
+ Arguments(0)
14847
+ Initializer:
14848
+ null
14849
+ Arguments(0)
14850
+ InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
14851
+ OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
14852
+ IArgumentOperation (ArgumentKind.Explicit, Matching Parameter: resultSelector) (OperationKind.Argument, Type: null, IsImplicit) (Syntax: 'x.ToString( ... .ToString()')
14853
+ IDelegateCreationOperation (OperationKind.DelegateCreation, Type: System.Func<System.Int32, System.Int32, System.String>, IsImplicit) (Syntax: 'x.ToString( ... .ToString()')
14854
+ Target:
14855
+ IAnonymousFunctionOperation (Symbol: lambda expression) (OperationKind.AnonymousFunction, Type: null, IsImplicit) (Syntax: 'x.ToString( ... .ToString()')
14856
+ IBlockOperation (1 statements) (OperationKind.Block, Type: null, IsImplicit) (Syntax: 'x.ToString( ... .ToString()')
14857
+ IReturnOperation (OperationKind.Return, Type: null, IsImplicit) (Syntax: 'x.ToString( ... .ToString()')
14858
+ ReturnedValue:
14859
+ IBinaryOperation (BinaryOperatorKind.Add) (OperationKind.Binary, Type: System.String) (Syntax: 'x.ToString( ... .ToString()')
14860
+ Left:
14861
+ IInvocationOperation (virtual System.String System.Int32.ToString()) (OperationKind.Invocation, Type: System.String) (Syntax: 'x.ToString()')
14862
+ Instance Receiver:
14863
+ IParameterReferenceOperation: x (OperationKind.ParameterReference, Type: System.Int32) (Syntax: 'x')
14864
+ Arguments(0)
14865
+ Right:
14866
+ IInvocationOperation (virtual System.String System.Int32.ToString()) (OperationKind.Invocation, Type: System.String) (Syntax: 'y.ToString()')
14867
+ Instance Receiver:
14868
+ IParameterReferenceOperation: y (OperationKind.ParameterReference, Type: System.Int32) (Syntax: 'y')
14869
+ Arguments(0)
14870
+ InConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
14871
+ OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
14872
+ """ ;
14873
+ VerifyOperationTreeAndDiagnosticsForTest < QueryExpressionSyntax > ( src , expectedOperationTree , [ ] ) ;
14874
+ }
14800
14875
}
14801
14876
0 commit comments