Skip to content

Commit 44e1a20

Browse files
eduardo-vpEduardo VelardeCopilot
authored
Fix MethodBase.GetCurrentMethod with runtime async (#122710)
Fixes #122546. --------- Co-authored-by: Eduardo Velarde <evelardepola@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 3412913 commit 44e1a20

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ public MethodDesc ExpandIntrinsicForCallsite(MethodDesc intrinsicMethod, MethodD
204204
{
205205
if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.Name.SequenceEqual("GetCurrentMethod"u8))
206206
{
207+
if (callsiteMethod.IsAsyncVariant())
208+
{
209+
// For async methods, we need to get the MethodBase for the thunk variant.
210+
callsiteMethod = TypeSystemContext.GetTargetOfAsyncVariantMethod(callsiteMethod);
211+
}
207212
return _methodBaseGetCurrentMethodThunks.GetHelper(callsiteMethod).InstantiateAsOpen();
208213
}
209214
}

src/tests/async/reflection/reflection.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ public static void UnsafeAccessors()
247247
}
248248

249249
[Fact]
250-
[ActiveIssue("https://github.com/dotnet/runtime/issues/122517", typeof(TestLibrary.Utilities), nameof(TestLibrary.Utilities.IsNativeAot))]
251250
public static void CurrentMethod()
252251
{
253252
// Note: async1 leaks implementation details here and returns "Void MoveNext()"

0 commit comments

Comments
 (0)