Skip to content

Commit 599996a

Browse files
Fix GetInterfaceMap with respect to generics (#113611)
This API is still generally broken because the partial implementation from dotnet/corert#8144 is still only partial, but this should either return correct result or throw. Here we can compute the correct result. Full fix still tracked at #89157.
1 parent e12a753 commit 599996a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.Runtime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public sealed override void GetInterfaceMap(Type instanceType, [DynamicallyAcces
3838
goto notFound;
3939
}
4040

41-
MethodBase methodBase = ReflectionExecution.GetMethodBaseFromStartAddressIfAvailable(classRtMethodHandle);
41+
MethodBase methodBase = ReflectionExecution.GetMethodBaseFromOriginalLdftnResult(classRtMethodHandle, instanceType.TypeHandle);
4242
if (methodBase == null)
4343
{
4444
goto notFound;

src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ReflectionExecution.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ public static MethodBase GetMethodBaseFromStartAddressIfAvailable(IntPtr methodS
9494
return ExecutionDomain.GetMethod(declaringTypeHandle, qMethodDefinition, genericMethodTypeArgumentHandles: null);
9595
}
9696

97+
public static MethodBase GetMethodBaseFromOriginalLdftnResult(IntPtr methodStartAddress, RuntimeTypeHandle declaringTypeHandle)
98+
{
99+
if (!ExecutionEnvironment.TryGetMethodForOriginalLdFtnResult(methodStartAddress,
100+
ref declaringTypeHandle, out QMethodDefinition qMethodDefinition, out RuntimeTypeHandle[] genericMethodTypeArgumentHandles))
101+
{
102+
return null;
103+
}
104+
105+
return ExecutionDomain.GetMethod(declaringTypeHandle, qMethodDefinition, genericMethodTypeArgumentHandles);
106+
}
107+
97108
internal static ExecutionEnvironmentImplementation ExecutionEnvironment { get; private set; }
98109
}
99110
}

0 commit comments

Comments
 (0)