diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs index 447d98dd46ee82..0b8d50589b9b5e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs @@ -423,6 +423,16 @@ public override MethodIL EmitIL() Array.Empty()); } + // TODO: (async) https://github.com/dotnet/runtime/issues/121781 + if (_targetMethod.IsAsyncCall()) + { + ILEmitter e = new ILEmitter(); + ILCodeStream c = e.NewCodeStream(); + + c.EmitCallThrowHelper(e, Context.GetCoreLibEntryPoint("System.Runtime"u8, "InternalCalls"u8, "RhpFallbackFailFast"u8, null)); + return e.Link(this); + } + // Generate the unboxing stub. This loosely corresponds to following C#: // return BoxedValue.InstanceMethod(this.m_pEEType, [rest of parameters]) @@ -520,6 +530,16 @@ public override MethodIL EmitIL() Array.Empty()); } + // TODO: (async) https://github.com/dotnet/runtime/issues/121781 + if (_targetMethod.IsAsyncCall()) + { + ILEmitter e = new ILEmitter(); + ILCodeStream c = e.NewCodeStream(); + + c.EmitCallThrowHelper(e, Context.GetCoreLibEntryPoint("System.Runtime"u8, "InternalCalls"u8, "RhpFallbackFailFast"u8, null)); + return e.Link(this); + } + // Generate the unboxing stub. This loosely corresponds to following C#: // return BoxedValue.InstanceMethod([rest of parameters]) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs index 005d5d40053149..7eb8b349d1d1d0 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs @@ -217,6 +217,16 @@ public override string DiagnosticName public override MethodIL EmitIL() { + // TODO: (async) https://github.com/dotnet/runtime/issues/121781 + if (_targetMethod.IsAsyncCall()) + { + ILEmitter e = new ILEmitter(); + ILCodeStream c = e.NewCodeStream(); + + c.EmitCallThrowHelper(e, Context.GetCoreLibEntryPoint("System.Runtime"u8, "InternalCalls"u8, "RhpFallbackFailFast"u8, null)); + return e.Link(this); + } + // Generate the instantiating stub. This loosely corresponds to following C#: // return Interface.Method(this, GetOrdinalInterface(this.m_pEEType, Index), [rest of parameters]) diff --git a/src/tests/async/inst-unbox-thunks/inst-unbox-thunks.cs b/src/tests/async/inst-unbox-thunks/inst-unbox-thunks.cs index 8a727672443835..3af178b89a15d1 100644 --- a/src/tests/async/inst-unbox-thunks/inst-unbox-thunks.cs +++ b/src/tests/async/inst-unbox-thunks/inst-unbox-thunks.cs @@ -115,24 +115,28 @@ public static void ManyArgUnbox() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/121781", typeof(TestLibrary.Utilities), nameof(TestLibrary.Utilities.IsNativeAot))] public static void NoArgGenericUnbox() { Assert.Equal("System.String", CallStruct1M0().Result); } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/121781", typeof(TestLibrary.Utilities), nameof(TestLibrary.Utilities.IsNativeAot))] public static void ManyArgGenericUnbox() { Assert.Equal("System.String", CallStruct1M1().Result); } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/121781", typeof(TestLibrary.Utilities), nameof(TestLibrary.Utilities.IsNativeAot))] public static void NoArgGenericInstantiating() { Assert.Equal("System.String", CallStruct1M0b().Result); } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/121781", typeof(TestLibrary.Utilities), nameof(TestLibrary.Utilities.IsNativeAot))] public static void ManyArgGenericInstantiating() { Assert.Equal("System.String", CallStruct1M1b().Result); @@ -183,4 +187,48 @@ public static void ManyArgGVM() { Assert.Equal("System.String", CallClass2M1().Result); } + + interface I3 + { + async Task M0() + { + await Task.Yield(); + return typeof(T).ToString(); + } + + async Task M1(object a0, object a1, object a2, object a3, object a4, object a5, object a6, object a7, object a8) + { + await Task.Yield(); + return typeof(T).ToString(); + } + } + + class Class3 : I3; + + static I3 o3; + static async Task CallClass3M0() + { + o3 = new Class3(); + return await o3.M0(); + } + + static async Task CallClass3M1() + { + o3 = new Class3(); + return await o3.M1(default, default, default, default, default, default, default, default, default); + } + + [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/121781", typeof(TestLibrary.Utilities), nameof(TestLibrary.Utilities.IsNativeAot))] + public static void NoArgDefaultMethod() + { + Assert.Equal("System.String", CallClass3M0().Result); + } + + [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/121781", typeof(TestLibrary.Utilities), nameof(TestLibrary.Utilities.IsNativeAot))] + public static void ManyArgDefaultMethod() + { + Assert.Equal("System.String", CallClass3M1().Result); + } } diff --git a/src/tests/async/inst-unbox-thunks/inst-unbox-thunks.csproj b/src/tests/async/inst-unbox-thunks/inst-unbox-thunks.csproj index 9367a79b2edbb1..cca27b669aeeac 100644 --- a/src/tests/async/inst-unbox-thunks/inst-unbox-thunks.csproj +++ b/src/tests/async/inst-unbox-thunks/inst-unbox-thunks.csproj @@ -5,4 +5,7 @@ + + +