-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Interface maps' TargetMethods array should only contain generic method definitions, not instances #98790
Conversation
…d definitions, not instances
src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs
Outdated
Show resolved
Hide resolved
im.TargetMethods[i] = (MethodInfo)rtTypeMethodBase!; | ||
MethodInfo targetMethod = (MethodInfo)rtTypeMethodBase!; | ||
// https://github.com/dotnet/runtime/issues/90863 | ||
if (targetMethod.IsGenericMethod && !targetMethod.IsGenericMethodDefinition) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment a few lines above says that targetMethod
can be null. We will crash with null reference exception if that happens. Are we missing a test for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I'll just make this null safe.
src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Should fix #90863.
Under some circumstances, an interface map can end up containing invalid generic method instances where a generic method definition should be. The runtime internals do not thoroughly validate generic method instances at construction time, and it's not straightforward (or necessarily possible at all) to tighten the validation to prevent these instances from making it into the runtime representation or prevent them from being constructed.
So this PR adds a simple validation check to the C# layer that exposes the interface map, and if it sees a generic method instance, it grabs the definition for that instance instead and puts it in the interface map.
Re-enables a disabled test data item that covers this scenario.