Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VB: Do not use overload resolution for expression tree conversion #75490

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ private BoundExpression VisitObjectCreationExpressionInternal(BoundObjectCreatio
}
else
{
return _bound.StaticCall(WellKnownMember.System_Linq_Expressions_Expression__New_ConstructorInfo_Expressions, ctor, args);
return _bound.StaticCall(WellKnownMember.System_Linq_Expressions_Expression__New_ConstructorInfo_IEnumerableExpressions, ctor, args);
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/Compilers/Core/Portable/WellKnownMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,8 @@ internal enum WellKnownMember
System_Linq_Expressions_Expression__Not_Expression,
System_Linq_Expressions_Expression__Not_Expression_MethodInfo,
System_Linq_Expressions_Expression__New_Type,
System_Linq_Expressions_Expression__New_ConstructorInfo_Expressions,
System_Linq_Expressions_Expression__New_ConstructorInfo_IEnumerableExpressions,
System_Linq_Expressions_Expression__New_ConstructorInfo_ArrayExpressions,
System_Linq_Expressions_Expression__New_ConstructorInfo_Expressions_MemberInfos,
System_Linq_Expressions_Expression__Property,
System_Linq_Expressions_Expression__MemberBind_MemberInfo,
Expand Down Expand Up @@ -710,6 +711,8 @@ internal enum WellKnownMember
System_Linq_Expressions_Expression__GreaterThan_MethodInfo,
System_Linq_Expressions_Expression__GreaterThanOrEqual,
System_Linq_Expressions_Expression__GreaterThanOrEqual_MethodInfo,
System_Linq_Expressions_Expression__Default,
System_Linq_Expressions_Expression__Power_MethodInfo,

Count,

Expand Down
34 changes: 32 additions & 2 deletions src/Compilers/Core/Portable/WellKnownMembers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4447,7 +4447,7 @@ static WellKnownMembers()
(byte)SignatureTypeCode.TypeHandle, (byte)WellKnownType.ExtSentinel, (byte)(WellKnownType.System_Linq_Expressions_NewExpression - WellKnownType.ExtSentinel), // Return Type
(byte)SignatureTypeCode.TypeHandle, (byte)WellKnownType.System_Type,

// System_Linq_Expressions_Expression__New_ConstructorInfo_Expressions,
// System_Linq_Expressions_Expression__New_ConstructorInfo_IEnumerableExpressions,
(byte)(MemberFlags.Method | MemberFlags.Static), // Flags
(byte)WellKnownType.System_Linq_Expressions_Expression, // DeclaringTypeId
0, // Arity
Expand All @@ -4459,6 +4459,15 @@ static WellKnownMembers()
1,
(byte)SignatureTypeCode.TypeHandle, (byte)WellKnownType.System_Linq_Expressions_Expression,

// System_Linq_Expressions_Expression__New_ConstructorInfo_ArrayExpressions,
(byte)(MemberFlags.Method | MemberFlags.Static), // Flags
(byte)WellKnownType.System_Linq_Expressions_Expression, // DeclaringTypeId
0, // Arity
2, // Method Signature
(byte)SignatureTypeCode.TypeHandle, (byte)WellKnownType.ExtSentinel, (byte)(WellKnownType.System_Linq_Expressions_NewExpression - WellKnownType.ExtSentinel), // Return Type
(byte)SignatureTypeCode.TypeHandle, (byte)WellKnownType.System_Reflection_ConstructorInfo,
(byte)SignatureTypeCode.SZArray, (byte)SignatureTypeCode.TypeHandle, (byte)WellKnownType.System_Linq_Expressions_Expression,

// System_Linq_Expressions_Expression__New_ConstructorInfo_Expressions_MemberInfos,
(byte)(MemberFlags.Method | MemberFlags.Static), // Flags
(byte)WellKnownType.System_Linq_Expressions_Expression, // DeclaringTypeId
Expand Down Expand Up @@ -5143,6 +5152,24 @@ static WellKnownMembers()
(byte)SignatureTypeCode.TypeHandle, (byte)WellKnownType.System_Linq_Expressions_Expression,
(byte)SignatureTypeCode.TypeHandle, (byte)SpecialType.System_Boolean,
(byte)SignatureTypeCode.TypeHandle, (byte)WellKnownType.System_Reflection_MethodInfo,

// System_Linq_Expressions_Expression__Default
(byte)(MemberFlags.Method | MemberFlags.Static), // Flags
(byte)WellKnownType.System_Linq_Expressions_Expression, // DeclaringTypeId
0, // Arity
1, // Method Signature
(byte)SignatureTypeCode.TypeHandle, (byte)WellKnownType.ExtSentinel, (byte)(WellKnownType.System_Linq_Expressions_DefaultExpression - WellKnownType.ExtSentinel), // Return Type
(byte)SignatureTypeCode.TypeHandle, (byte)WellKnownType.System_Type,

// System_Linq_Expressions_Expression__Power_MethodInfo,
(byte)(MemberFlags.Method | MemberFlags.Static), // Flags
(byte)WellKnownType.System_Linq_Expressions_Expression, // DeclaringTypeId
0, // Arity
3, // Method Signature
(byte)SignatureTypeCode.TypeHandle, (byte)WellKnownType.ExtSentinel, (byte)(WellKnownType.System_Linq_Expressions_BinaryExpression - WellKnownType.ExtSentinel), // Return Type
(byte)SignatureTypeCode.TypeHandle, (byte)WellKnownType.System_Linq_Expressions_Expression,
(byte)SignatureTypeCode.TypeHandle, (byte)WellKnownType.System_Linq_Expressions_Expression,
(byte)SignatureTypeCode.TypeHandle, (byte)WellKnownType.System_Reflection_MethodInfo,
};

string[] allNames = new string[(int)WellKnownMember.Count]
Expand Down Expand Up @@ -5690,7 +5717,8 @@ static WellKnownMembers()
"Not", // System_Linq_Expressions_Expression__Not_Expression
"Not", // System_Linq_Expressions_Expression__Not_Expression_MethodInfo
"New", // System_Linq_Expressions_Expression__New_Type
"New", // System_Linq_Expressions_Expression__New_ConstructorInfo_Expressions
"New", // System_Linq_Expressions_Expression__New_ConstructorInfo_IEnumerableExpressions
"New", // System_Linq_Expressions_Expression__New_ConstructorInfo_ArrayExpressions
"New", // System_Linq_Expressions_Expression__New_ConstructorInfo_Expressions_MemberInfos
"Property", // System_Linq_Expressions_Expression__Property
"MemberBind", // System_Linq_Expressions_Expression__MemberBind_MemberInfo
Expand Down Expand Up @@ -5763,6 +5791,8 @@ static WellKnownMembers()
"GreaterThan", // System_Linq_Expressions_Expression__GreaterThan_MethodInfo,
"GreaterThanOrEqual", // System_Linq_Expressions_Expression__GreaterThanOrEqual,
"GreaterThanOrEqual", // System_Linq_Expressions_Expression__GreaterThanOrEqual_MethodInfo,
"Default", // System_Linq_Expressions_Expression__Default
"Power", // System_Linq_Expressions_Expression__Power_MethodInfo,
};

s_descriptors = MemberDescriptor.InitializeFromStream(new System.IO.MemoryStream(initializationBytes, writable: false), allNames);
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/WellKnownTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ internal enum WellKnownType
System_Linq_Expressions_ConditionalExpression,
System_Linq_Expressions_InvocationExpression,
System_Linq_Expressions_NewArrayExpression,
System_Linq_Expressions_DefaultExpression,

NextAvailable,
// Remember to update the AllWellKnownTypes tests when making changes here
Expand Down Expand Up @@ -693,6 +694,7 @@ internal static class WellKnownTypes
"System.Linq.Expressions.ConditionalExpression",
"System.Linq.Expressions.InvocationExpression",
"System.Linq.Expressions.NewArrayExpression",
"System.Linq.Expressions.DefaultExpression",
};

private static readonly Dictionary<string, WellKnownType> s_nameToTypeIdMap = new Dictionary<string, WellKnownType>((int)Count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Debug.Assert(Type.Equals(UnderlyingExpression.Type))
Debug.Assert((OperatorKind And BinaryOperatorKind.UserDefined) <> 0)
Debug.Assert(UnderlyingExpression.Kind = BoundKind.BadExpression OrElse UnderlyingExpression.Kind = BoundKind.Call)
Debug.Assert((OperatorKind And BinaryOperatorKind.OpMask) <> BinaryOperatorKind.AndAlso)
Debug.Assert((OperatorKind And BinaryOperatorKind.OpMask) <> BinaryOperatorKind.OrElse)

If UnderlyingExpression.Kind = BoundKind.Call Then
Dim underlyingCall = DirectCast(UnderlyingExpression, BoundCall)
Expand Down
Loading