diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index ea1e0c10ec9548..25634caea84e1c 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -633,6 +633,7 @@ enum CorInfoHelpFunc CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, // throw PlatformNotSupportedException CORINFO_HELP_THROW_TYPE_NOT_SUPPORTED, // throw TypeNotSupportedException CORINFO_HELP_THROW_AMBIGUOUS_RESOLUTION_EXCEPTION, // throw AmbiguousResolutionException for failed static virtual method resolution + CORINFO_HELP_THROW_ENTRYPOINT_NOT_FOUND_EXCEPTION, // throw EntryPointNotFoundException for failed static virtual method resolution CORINFO_HELP_JIT_PINVOKE_BEGIN, // Transition to preemptive mode before a P/Invoke, frame is the first argument CORINFO_HELP_JIT_PINVOKE_END, // Transition to cooperative mode after a P/Invoke, frame is the first argument diff --git a/src/coreclr/inc/jiteeversionguid.h b/src/coreclr/inc/jiteeversionguid.h index 6c6f7e8283c01d..bcd85a573d69bc 100644 --- a/src/coreclr/inc/jiteeversionguid.h +++ b/src/coreclr/inc/jiteeversionguid.h @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID; #define GUID_DEFINED #endif // !GUID_DEFINED -constexpr GUID JITEEVersionIdentifier = { /* 02e334af-4e6e-4a68-9feb-308d3d2661bc */ - 0x2e334af, - 0x4e6e, - 0x4a68, - {0x9f, 0xeb, 0x30, 0x8d, 0x3d, 0x26, 0x61, 0xbc} +constexpr GUID JITEEVersionIdentifier = { /* cef79bc8-29bf-4f7b-9d05-9fc06832098c */ + 0xcef79bc8, + 0x29bf, + 0x4f7b, + {0x9d, 0x05, 0x9f, 0xc0, 0x68, 0x32, 0x09, 0x8c} }; ////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/coreclr/inc/jithelpers.h b/src/coreclr/inc/jithelpers.h index 1913a428da9425..d34696ac1c9830 100644 --- a/src/coreclr/inc/jithelpers.h +++ b/src/coreclr/inc/jithelpers.h @@ -317,6 +317,7 @@ JITHELPER(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, JIT_ThrowPlatformNotSupportedException, CORINFO_HELP_SIG_REG_ONLY) JITHELPER(CORINFO_HELP_THROW_TYPE_NOT_SUPPORTED, JIT_ThrowTypeNotSupportedException, CORINFO_HELP_SIG_REG_ONLY) JITHELPER(CORINFO_HELP_THROW_AMBIGUOUS_RESOLUTION_EXCEPTION, JIT_ThrowAmbiguousResolutionException, CORINFO_HELP_SIG_REG_ONLY) + JITHELPER(CORINFO_HELP_THROW_ENTRYPOINT_NOT_FOUND_EXCEPTION, JIT_ThrowEntryPointNotFoundException, CORINFO_HELP_SIG_REG_ONLY) JITHELPER(CORINFO_HELP_JIT_PINVOKE_BEGIN, JIT_PInvokeBegin, CORINFO_HELP_SIG_REG_ONLY) JITHELPER(CORINFO_HELP_JIT_PINVOKE_END, JIT_PInvokeEnd, CORINFO_HELP_SIG_REG_ONLY) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs b/src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs index 0693f3c1b69f15..7837e8c24f832f 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs @@ -275,6 +275,7 @@ which is the right helper to use to allocate an object of a given type. */ CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, // throw PlatformNotSupportedException CORINFO_HELP_THROW_TYPE_NOT_SUPPORTED, // throw TypeNotSupportedException CORINFO_HELP_THROW_AMBIGUOUS_RESOLUTION_EXCEPTION, // throw AmbiguousResolutionException for failed static virtual method resolution + CORINFO_HELP_THROW_ENTRYPOINT_NOT_FOUND_EXCEPTION, // throw EntryPointNotFoundException for failed static virtual method resolution CORINFO_HELP_JIT_PINVOKE_BEGIN, // Transition to preemptive mode before a P/Invoke, frame is the first argument CORINFO_HELP_JIT_PINVOKE_END, // Transition to cooperative mode after a P/Invoke, frame is the first argument diff --git a/src/coreclr/vm/dllimport.h b/src/coreclr/vm/dllimport.h index d3ac9847abf7ba..256b950799336e 100644 --- a/src/coreclr/vm/dllimport.h +++ b/src/coreclr/vm/dllimport.h @@ -194,6 +194,7 @@ enum ILStubTypes ILSTUB_WRAPPERDELEGATE_INVOKE = 0x80000007, ILSTUB_TAILCALL_STOREARGS = 0x80000008, ILSTUB_TAILCALL_CALLTARGET = 0x80000009, + ILSTUB_STATIC_VIRTUAL_DISPATCH_STUB = 0x8000000A, }; #ifdef FEATURE_COMINTEROP @@ -214,6 +215,8 @@ inline bool SF_IsForNumParamBytes (DWORD dwStubFlags) { LIMITED_METHOD_CONT inline bool SF_IsStructMarshalStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_STRUCT_MARSHAL)); } inline bool SF_IsCheckPendingException (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_CHECK_PENDING_EXCEPTION)); } +inline bool SF_IsVirtualStaticMethodDispatchStub(DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return dwStubFlags == ILSTUB_STATIC_VIRTUAL_DISPATCH_STUB; } + #ifdef FEATURE_ARRAYSTUB_AS_IL inline bool SF_IsArrayOpStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return ((dwStubFlags == ILSTUB_ARRAYOP_GET) || (dwStubFlags == ILSTUB_ARRAYOP_SET) || diff --git a/src/coreclr/vm/genericdict.cpp b/src/coreclr/vm/genericdict.cpp index 2a79009f4cbd78..456bec758b2a64 100644 --- a/src/coreclr/vm/genericdict.cpp +++ b/src/coreclr/vm/genericdict.cpp @@ -29,6 +29,7 @@ #include "typectxt.h" #include "virtualcallstub.h" #include "sigbuilder.h" +#include "dllimport.h" #ifndef DACCESS_COMPILE @@ -599,6 +600,70 @@ Dictionary* Dictionary::GetTypeDictionaryWithSizeCheck(MethodTable* pMT, ULONG s RETURN pDictionary; } +struct StaticVirtualDispatchHashBlob : public ILStubHashBlobBase +{ + MethodDesc *pExactInterfaceMethod; + MethodTable *pTargetMT; +}; + +PCODE CreateStubForStaticVirtualDispatch(MethodTable* pTargetMT, MethodTable* pInterfaceMT, MethodDesc *pInterfaceMD) +{ + GCX_PREEMP(); + + Module* pLoaderModule = ClassLoader::ComputeLoaderModule(pTargetMT, 0, pInterfaceMD->GetMethodInstantiation()); + + MethodDesc *pExactMD = MethodDesc::FindOrCreateAssociatedMethodDesc( + pInterfaceMD, + pInterfaceMT, + FALSE, // forceBoxedEntryPoint + pInterfaceMD->GetMethodInstantiation(), // methodInst + FALSE, // allowInstParam + TRUE); // forceRemotableMethod + + StaticVirtualDispatchHashBlob hashBlob; + memset(&hashBlob, 0, sizeof(hashBlob)); + hashBlob.pExactInterfaceMethod = pExactMD; + hashBlob.pTargetMT = pTargetMT; + hashBlob.m_cbSizeOfBlob = sizeof(hashBlob); + ILStubHashBlob *pHashBlob = (ILStubHashBlob*)&hashBlob; + + MethodDesc *pStubMD = pLoaderModule->GetILStubCache()->LookupStubMethodDesc(pHashBlob); + if (pStubMD == NULL) + { + SigTypeContext context(pExactMD); + ILStubLinker sl(pExactMD->GetModule(), pExactMD->GetSignature(), &context, pExactMD, ILSTUB_LINKER_FLAG_NONE); + MetaSig sig(pInterfaceMD); + + ILCodeStream *pCode = sl.NewCodeStream(ILStubLinker::kDispatch); + + UINT paramCount = 0; + BOOL fReturnVal = !sig.IsReturnTypeVoid(); + while(paramCount < sig.NumFixedArgs()) + pCode->EmitLDARG(paramCount++); + + pCode->EmitCONSTRAINED(pCode->GetToken(pTargetMT)); + pCode->EmitCALL(pCode->GetToken(pInterfaceMD), sig.NumFixedArgs(), fReturnVal); + pCode->EmitRET(); + + PCCOR_SIGNATURE pSig; + DWORD cbSig; + + pInterfaceMD->GetSig(&pSig,&cbSig); + + pStubMD = ILStubCache::CreateAndLinkNewILStubMethodDesc(pLoaderModule->GetLoaderAllocator(), + pLoaderModule->GetILStubCache()->GetOrCreateStubMethodTable(pLoaderModule), + ILSTUB_STATIC_VIRTUAL_DISPATCH_STUB, + pInterfaceMD->GetModule(), + pSig, cbSig, + &context, + &sl); + + pStubMD = pLoaderModule->GetILStubCache()->InsertStubMethodDesc(pStubMD, pHashBlob); + } + + return JitILStub(pStubMD); +} + //--------------------------------------------------------------------------------------- // DictionaryEntry @@ -1068,11 +1133,40 @@ Dictionary::PopulateEntry( } _ASSERTE(!constraintType.IsNull()); - MethodDesc *pResolvedMD = constraintType.GetMethodTable()->TryResolveConstraintMethodApprox(ownerType, pMethod); + MethodDesc *pResolvedMD; - // All such calls should be resolvable. If not then for now just throw an error. - _ASSERTE(pResolvedMD); - INDEBUG(if (!pResolvedMD) constraintType.GetMethodTable()->TryResolveConstraintMethodApprox(ownerType, pMethod);) + if (pMethod->IsStatic()) + { + // Virtual Static Method resolution + _ASSERTE(!ownerType.IsTypeDesc()); + _ASSERTE(ownerType.IsInterface()); + BOOL uniqueResolution; + pResolvedMD = constraintType.GetMethodTable()->ResolveVirtualStaticMethod( + ownerType.GetMethodTable(), + pMethod, + /* allowNullResult */ TRUE, + /* verifyImplemented */ FALSE, + /* allowVariantMatches */ TRUE, + &uniqueResolution); + + // If we couldn't get an exact result, fall back to using a stub to make the exact function call + // This will trigger the logic in the JIT which can handle AmbiguousImplementationException and + // EntryPointNotFoundException at exactly the right time + if (!uniqueResolution || pResolvedMD == NULL || pResolvedMD->IsAbstract()) + { + _ASSERTE(pResolvedMD == NULL || pResolvedMD->IsStatic()); + result = (CORINFO_GENERIC_HANDLE)CreateStubForStaticVirtualDispatch(constraintType.GetMethodTable(), ownerType.GetMethodTable(), pMethod); + break; + } + } + else + { + pResolvedMD = constraintType.GetMethodTable()->TryResolveConstraintMethodApprox(ownerType, pMethod); + + // All such calls should be resolvable. If not then for now just throw an error. + _ASSERTE(pResolvedMD); + INDEBUG(if (!pResolvedMD) constraintType.GetMethodTable()->TryResolveConstraintMethodApprox(ownerType, pMethod);) + } if (!pResolvedMD) COMPlusThrowHR(COR_E_BADIMAGEFORMAT); diff --git a/src/coreclr/vm/ilstubcache.cpp b/src/coreclr/vm/ilstubcache.cpp index 8737bbd33bfba3..4c955e322bb73e 100644 --- a/src/coreclr/vm/ilstubcache.cpp +++ b/src/coreclr/vm/ilstubcache.cpp @@ -159,6 +159,7 @@ namespace case DynamicMethodDesc::StubWrapperDelegate: return "IL_STUB_WrapperDelegate_Invoke"; case DynamicMethodDesc::StubTailCallStoreArgs: return "IL_STUB_StoreTailCallArgs"; case DynamicMethodDesc::StubTailCallCallTarget: return "IL_STUB_CallTailCallTarget"; + case DynamicMethodDesc::StubVirtualStaticMethodDispatch: return "IL_STUB_bVirtualStaticMethodDispatch"; default: UNREACHABLE_MSG("Unknown stub type"); } @@ -319,6 +320,11 @@ MethodDesc* ILStubCache::CreateNewMethodDesc(LoaderHeap* pCreationHeap, MethodTa } } + if (SF_IsVirtualStaticMethodDispatchStub(dwStubFlags)) + { + pMD->SetILStubType(DynamicMethodDesc::StubVirtualStaticMethodDispatch); + } + // if we made it this far, we can set a more descriptive stub name #ifdef FEATURE_ARRAYSTUB_AS_IL if (SF_IsArrayOpStub(dwStubFlags)) @@ -397,6 +403,45 @@ MethodTable* ILStubCache::GetOrCreateStubMethodTable(Module* pModule) RETURN m_pStubMT; } + +MethodDesc* ILStubCache::LookupStubMethodDesc(ILStubHashBlob* pHashBlob) +{ + CrstHolder ch(&m_crst); + + // Try to find the stub + const ILStubCacheEntry* phe = m_hashMap.LookupPtr(pHashBlob); + if (phe) + { + return phe->m_pMethodDesc; + } + + return NULL; +} + +MethodDesc* ILStubCache::InsertStubMethodDesc(MethodDesc *pMD, ILStubHashBlob* pHashBlob) +{ + size_t cbSizeOfBlob = pHashBlob->m_cbSizeOfBlob; + + CrstHolder ch(&m_crst); + + const ILStubCacheEntry* phe = m_hashMap.LookupPtr(pHashBlob); + if (phe == NULL) + { + AllocMemHolder pBlobHolder( m_heap->AllocMem(S_SIZE_T(cbSizeOfBlob)) ); + ILStubHashBlob* pBlob = pBlobHolder; + _ASSERTE(pHashBlob->m_cbSizeOfBlob == cbSizeOfBlob); + memcpy(pBlob, pHashBlob, cbSizeOfBlob); + + m_hashMap.Add(ILStubCacheEntry{ pMD, pBlob }); + pBlobHolder.SuppressRelease(); + + return pMD; + } + else + { + return phe->m_pMethodDesc; + } +} #endif // DACCESS_COMPILE // diff --git a/src/coreclr/vm/ilstubcache.h b/src/coreclr/vm/ilstubcache.h index d70d1baac6c602..b101e14f2c4fba 100644 --- a/src/coreclr/vm/ilstubcache.h +++ b/src/coreclr/vm/ilstubcache.h @@ -79,6 +79,12 @@ class ILStubCache final MethodTable* GetOrCreateStubMethodTable(Module* pLoaderModule); + MethodDesc* LookupStubMethodDesc(ILStubHashBlob* pHashBlob); + + // Insert a stub MethodDesc into the cache + // If one is already present at a matching hash blob, return the already present one, otherwise, return pMD + MethodDesc* InsertStubMethodDesc(MethodDesc* pMD, ILStubHashBlob* pHashBlob); + private: // static static MethodDesc* CreateNewMethodDesc( LoaderHeap* pCreationHeap, diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index acb8cefb6942be..d5945f36582bbe 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -4428,6 +4428,38 @@ HCIMPL3(void, JIT_ThrowAmbiguousResolutionException, } HCIMPLEND +/*********************************************************************/ +HCIMPL3(void, JIT_ThrowEntryPointNotFoundException, + MethodDesc *method, + MethodTable *interfaceType, + MethodTable *targetType) +{ + FCALL_CONTRACT; + + HELPER_METHOD_FRAME_BEGIN_0(); // Set up a frame + + SString strMethodName; + SString strInterfaceName; + SString strTargetClassName; + SString assemblyName; + + targetType->GetAssembly()->GetDisplayName(assemblyName); + TypeString::AppendMethod(strMethodName, method, method->GetMethodInstantiation()); + TypeString::AppendType(strInterfaceName, TypeHandle(interfaceType)); + TypeString::AppendType(strTargetClassName, targetType); + + COMPlusThrow( + kEntryPointNotFoundException, + IDS_CLASSLOAD_METHOD_NOT_IMPLEMENTED, + strMethodName, + strInterfaceName, + strTargetClassName, + assemblyName); + + HELPER_METHOD_FRAME_END(); // Set up a frame +} +HCIMPLEND + /*********************************************************************/ HCIMPL0(void, JIT_Overflow) { diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index f105806bc532be..840b2b9cd390ab 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -5069,6 +5069,7 @@ void CEEInfo::getCallInfo( BOOL fResolvedConstraint = FALSE; BOOL fForceUseRuntimeLookup = FALSE; + BOOL fAbstractSVM = FALSE; MethodDesc * pMDAfterConstraintResolution = pMD; if (constrainedType.IsNull()) @@ -5149,11 +5150,21 @@ void CEEInfo::getCallInfo( #ifdef FEATURE_DEFAULT_INTERFACES else if (directMethod && pMD->IsStatic()) { - // Default interface implementation of static virtual method - pMDAfterConstraintResolution = directMethod; - fResolvedConstraint = TRUE; - pResult->thisTransform = CORINFO_NO_THIS_TRANSFORM; - exactType = directMethod->GetMethodTable(); + if (directMethod->IsAbstract()) + { + // This is the result when we call a SVM which is abstract, or re-abstracted + directMethod = NULL; + pResult->thisTransform = CORINFO_NO_THIS_TRANSFORM; + fAbstractSVM = true; + } + else + { + // Default interface implementation of static virtual method + pMDAfterConstraintResolution = directMethod; + fResolvedConstraint = TRUE; + pResult->thisTransform = CORINFO_NO_THIS_TRANSFORM; + exactType = directMethod->GetMethodTable(); + } } #endif else if (constrainedType.IsValueType()) @@ -5650,7 +5661,14 @@ void CEEInfo::getCallInfo( // shared generics is covered by the ConstrainedMethodEntrySlot dictionary entry. pResult->kind = CORINFO_CALL; pResult->accessAllowed = CORINFO_ACCESS_ILLEGAL; - pResult->callsiteCalloutHelper.helperNum = CORINFO_HELP_THROW_AMBIGUOUS_RESOLUTION_EXCEPTION; + if (fAbstractSVM) + { + pResult->callsiteCalloutHelper.helperNum = CORINFO_HELP_THROW_ENTRYPOINT_NOT_FOUND_EXCEPTION; + } + else + { + pResult->callsiteCalloutHelper.helperNum = CORINFO_HELP_THROW_AMBIGUOUS_RESOLUTION_EXCEPTION; + } pResult->callsiteCalloutHelper.numArgs = 3; pResult->callsiteCalloutHelper.args[0].methodHandle = (CORINFO_METHOD_HANDLE)pMD; pResult->callsiteCalloutHelper.args[0].argType = CORINFO_HELPER_ARG_TYPE_Method; diff --git a/src/coreclr/vm/method.hpp b/src/coreclr/vm/method.hpp index 02783201fcd3a7..f0dbbf3894edf5 100644 --- a/src/coreclr/vm/method.hpp +++ b/src/coreclr/vm/method.hpp @@ -2458,6 +2458,8 @@ class DynamicMethodDesc : public StoredSigMethodDesc StubTailCallStoreArgs, StubTailCallCallTarget, + StubVirtualStaticMethodDispatch, + StubLast }; diff --git a/src/coreclr/vm/stubgen.cpp b/src/coreclr/vm/stubgen.cpp index d96b3779f4f912..78e7fb621c90d5 100644 --- a/src/coreclr/vm/stubgen.cpp +++ b/src/coreclr/vm/stubgen.cpp @@ -1237,6 +1237,11 @@ void ILCodeStream::EmitCLT_UN() WRAPPER_NO_CONTRACT; Emit(CEE_CLT_UN, -1, 0); } +void ILCodeStream::EmitCONSTRAINED(int token) +{ + WRAPPER_NO_CONTRACT; + Emit(CEE_CONSTRAINED, 0, token); +} void ILCodeStream::EmitCONV_I() { WRAPPER_NO_CONTRACT; diff --git a/src/coreclr/vm/stubgen.h b/src/coreclr/vm/stubgen.h index 5c83f23a94aed6..595de649220cc5 100644 --- a/src/coreclr/vm/stubgen.h +++ b/src/coreclr/vm/stubgen.h @@ -720,6 +720,7 @@ class ILCodeStream void EmitCGT_UN (); void EmitCLT (); void EmitCLT_UN (); + void EmitCONSTRAINED(int token); void EmitCONV_I (); void EmitCONV_I1 (); void EmitCONV_I2 (); diff --git a/src/tests/Loader/classloader/StaticVirtualMethods/NegativeTestCases/AmbiguousImplementationException.cs b/src/tests/Loader/classloader/StaticVirtualMethods/NegativeTestCases/AmbiguousImplementationException.cs new file mode 100644 index 00000000000000..9b4384a171cc7b --- /dev/null +++ b/src/tests/Loader/classloader/StaticVirtualMethods/NegativeTestCases/AmbiguousImplementationException.cs @@ -0,0 +1,68 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +// This is the C# skeleton that was used to build AmbiguousImplementationException.il. +// The only difference is to change the BarClass and BarStruct types +// to implement IBaz instead of IBoring + +using System; +using System.Runtime; +using Xunit; + +class VirtualStaticMethodReabstraction +{ + static int Main() + { + Assert.Throws(() => { Call(); }); + Assert.Throws(() => { Call(); }); + Assert.Throws(() => { Call(); }); + Assert.Throws(() => { Call(); }); + Assert.Throws(() => { Call(); }); + Assert.Throws(() => { Call(); }); + + Assert.Throws(() => { GetAction()(); }); + Assert.Throws(() => { GetAction()(); }); + Assert.Throws(() => { GetAction()(); }); + Assert.Throws(() => { GetAction()(); }); + Assert.Throws(() => { GetAction()(); }); + Assert.Throws(() => { GetAction()(); }); + + return 100; + } + + static void Call() where T : IFoo => T.Frob(); + static void Call() where T : IFoo => T.Frob(); + + static Action GetAction() where T : IFoo => T.Frob; + static Action GetAction() where T : IFoo => T.Frob; + + interface IFoo + { + static virtual void Frob() => throw null; + static virtual void Frob() => throw null; + } + + interface IBar : IFoo + { + static void IFoo.Frob() => throw null; + static void IFoo.Frob() => throw null; + } + + interface IBaz : IFoo + { + static void IFoo.Frob() => throw null; + static void IFoo.Frob() => throw null; + } + + interface IBoring + { + } + + class BarClass : IBar, IBoring + { + } + + struct BarStruct : IBar, IBoring + { + } +} diff --git a/src/tests/Loader/classloader/StaticVirtualMethods/NegativeTestCases/AmbiguousImplementationException.il b/src/tests/Loader/classloader/StaticVirtualMethods/NegativeTestCases/AmbiguousImplementationException.il new file mode 100644 index 00000000000000..beca161c982a9c --- /dev/null +++ b/src/tests/Loader/classloader/StaticVirtualMethods/NegativeTestCases/AmbiguousImplementationException.il @@ -0,0 +1,592 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +// .NET IL Disassembler. Version 8.0.0-dev + + + +// Metadata version: v4.0.30319 +.assembly extern System.Runtime +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....: + .ver 8:0:0:0 +} +.assembly extern xunit.assert +{ + .publickeytoken = (8D 05 B1 BB 7A 6F DB 6C ) // ....zo.l + .ver 2:4:2:0 +} +.assembly AmbiguousImplementationException +{ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) + .custom instance void [System.Runtime]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + + // --- The following custom attribute is added automatically, do not uncomment ------- + // .custom instance void [System.Runtime]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 ) + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module AmbiguousImplementationException.dll +// MVID: {bfdbf727-e737-4c32-8ddd-926f5f4d7f5b} +.custom instance void [System.Runtime]System.Runtime.CompilerServices.RefSafetyRulesAttribute::.ctor(int32) = ( 01 00 0B 00 00 00 00 00 ) +.imagebase 0x00400000 +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 // WINDOWS_CUI +.corflags 0x00000001 // ILONLY +// Image base: 0x0000029CD37C0000 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class private auto ansi beforefieldinit VirtualStaticMethodReabstraction + extends [System.Runtime]System.Object +{ + .class interface abstract auto ansi nested private IFoo + { + .method public hidebysig static virtual + void Frob() cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: throw + } // end of method IFoo::Frob + + .method public hidebysig static virtual + void Frob() cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: throw + } // end of method IFoo::Frob + + } // end of class IFoo + + .class interface abstract auto ansi nested private IBar + implements VirtualStaticMethodReabstraction/IFoo + { + .method private hidebysig static void + VirtualStaticMethodReabstraction.IFoo.Frob() cil managed + { + .override VirtualStaticMethodReabstraction/IFoo::Frob + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: throw + } // end of method IBar::VirtualStaticMethodReabstraction.IFoo.Frob + + .method private hidebysig static void + VirtualStaticMethodReabstraction.IFoo.Frob() cil managed + { + .override VirtualStaticMethodReabstraction/IFoo::Frob + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: throw + } // end of method IBar::VirtualStaticMethodReabstraction.IFoo.Frob + + } // end of class IBar + + .class interface abstract auto ansi nested private IBaz + implements VirtualStaticMethodReabstraction/IFoo + { + .method private hidebysig static void + VirtualStaticMethodReabstraction.IFoo.Frob() cil managed + { + .override VirtualStaticMethodReabstraction/IFoo::Frob + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: throw + } // end of method IBaz::VirtualStaticMethodReabstraction.IFoo.Frob + + .method private hidebysig static void + VirtualStaticMethodReabstraction.IFoo.Frob() cil managed + { + .override VirtualStaticMethodReabstraction/IFoo::Frob + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: throw + } // end of method IBaz::VirtualStaticMethodReabstraction.IFoo.Frob + + } // end of class IBaz + + .class interface abstract auto ansi nested private IBoring + { + } // end of class IBoring + + .class auto ansi nested private beforefieldinit BarClass + extends [System.Runtime]System.Object + implements VirtualStaticMethodReabstraction/IBar, + VirtualStaticMethodReabstraction/IFoo, + VirtualStaticMethodReabstraction/IBaz + { + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [System.Runtime]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method BarClass::.ctor + + } // end of class BarClass + + .class sequential ansi sealed nested private beforefieldinit BarStruct + extends [System.Runtime]System.ValueType + implements VirtualStaticMethodReabstraction/IBar, + VirtualStaticMethodReabstraction/IFoo, + VirtualStaticMethodReabstraction/IBaz + { + .pack 0 + .size 1 + } // end of class BarStruct + + .class auto ansi serializable sealed nested private beforefieldinit '<>c' + extends [System.Runtime]System.Object + { + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public static initonly class VirtualStaticMethodReabstraction/'<>c' '<>9' + .field public static class [System.Runtime]System.Action '<>9__0_0' + .field public static class [System.Runtime]System.Action '<>9__0_1' + .field public static class [System.Runtime]System.Action '<>9__0_2' + .field public static class [System.Runtime]System.Action '<>9__0_3' + .field public static class [System.Runtime]System.Action '<>9__0_4' + .field public static class [System.Runtime]System.Action '<>9__0_5' + .field public static class [System.Runtime]System.Action '<>9__0_6' + .field public static class [System.Runtime]System.Action '<>9__0_7' + .field public static class [System.Runtime]System.Action '<>9__0_8' + .field public static class [System.Runtime]System.Action '<>9__0_9' + .field public static class [System.Runtime]System.Action '<>9__0_10' + .field public static class [System.Runtime]System.Action '<>9__0_11' + .method private hidebysig specialname rtspecialname static + void .cctor() cil managed + { + // Code size 11 (0xb) + .maxstack 8 + IL_0000: newobj instance void VirtualStaticMethodReabstraction/'<>c'::.ctor() + IL_0005: stsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_000a: ret + } // end of method '<>c'::.cctor + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [System.Runtime]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::.ctor + + .method assembly hidebysig instance void + '
b__0_0'() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: nop + IL_0001: call void VirtualStaticMethodReabstraction::Call() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::'
b__0_0' + + .method assembly hidebysig instance void + '
b__0_1'() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: nop + IL_0001: call void VirtualStaticMethodReabstraction::Call() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::'
b__0_1' + + .method assembly hidebysig instance void + '
b__0_2'() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: nop + IL_0001: call void VirtualStaticMethodReabstraction::Call() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::'
b__0_2' + + .method assembly hidebysig instance void + '
b__0_3'() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: nop + IL_0001: call void VirtualStaticMethodReabstraction::Call() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::'
b__0_3' + + .method assembly hidebysig instance void + '
b__0_4'() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: nop + IL_0001: call void VirtualStaticMethodReabstraction::Call() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::'
b__0_4' + + .method assembly hidebysig instance void + '
b__0_5'() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: nop + IL_0001: call void VirtualStaticMethodReabstraction::Call() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::'
b__0_5' + + .method assembly hidebysig instance void + '
b__0_6'() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: nop + IL_0001: call class [System.Runtime]System.Action VirtualStaticMethodReabstraction::GetAction() + IL_0006: callvirt instance void [System.Runtime]System.Action::Invoke() + IL_000b: nop + IL_000c: ret + } // end of method '<>c'::'
b__0_6' + + .method assembly hidebysig instance void + '
b__0_7'() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: nop + IL_0001: call class [System.Runtime]System.Action VirtualStaticMethodReabstraction::GetAction() + IL_0006: callvirt instance void [System.Runtime]System.Action::Invoke() + IL_000b: nop + IL_000c: ret + } // end of method '<>c'::'
b__0_7' + + .method assembly hidebysig instance void + '
b__0_8'() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: nop + IL_0001: call class [System.Runtime]System.Action VirtualStaticMethodReabstraction::GetAction() + IL_0006: callvirt instance void [System.Runtime]System.Action::Invoke() + IL_000b: nop + IL_000c: ret + } // end of method '<>c'::'
b__0_8' + + .method assembly hidebysig instance void + '
b__0_9'() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: nop + IL_0001: call class [System.Runtime]System.Action VirtualStaticMethodReabstraction::GetAction() + IL_0006: callvirt instance void [System.Runtime]System.Action::Invoke() + IL_000b: nop + IL_000c: ret + } // end of method '<>c'::'
b__0_9' + + .method assembly hidebysig instance void + '
b__0_10'() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: nop + IL_0001: call class [System.Runtime]System.Action VirtualStaticMethodReabstraction::GetAction() + IL_0006: callvirt instance void [System.Runtime]System.Action::Invoke() + IL_000b: nop + IL_000c: ret + } // end of method '<>c'::'
b__0_10' + + .method assembly hidebysig instance void + '
b__0_11'() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: nop + IL_0001: call class [System.Runtime]System.Action VirtualStaticMethodReabstraction::GetAction() + IL_0006: callvirt instance void [System.Runtime]System.Action::Invoke() + IL_000b: nop + IL_000c: ret + } // end of method '<>c'::'
b__0_11' + + } // end of class '<>c' + + .class abstract auto ansi sealed nested private beforefieldinit 'O__3_0`1'<(VirtualStaticMethodReabstraction/IFoo) T> + extends [System.Runtime]System.Object + { + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public static class [System.Runtime]System.Action '<0>__Frob' + } // end of class 'O__3_0`1' + + .class abstract auto ansi sealed nested private beforefieldinit 'O__4_0`2'<(VirtualStaticMethodReabstraction/IFoo) T,U> + extends [System.Runtime]System.Object + { + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public static class [System.Runtime]System.Action '<0>__Frob' + } // end of class 'O__4_0`2' + + .method private hidebysig static int32 + Main() cil managed + { + .entrypoint + // Code size 452 (0x1c4) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: nop + IL_0001: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_0' + IL_0006: dup + IL_0007: brtrue.s IL_0020 + + IL_0009: pop + IL_000a: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_000f: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_0'() + IL_0015: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_001a: dup + IL_001b: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_0' + IL_0020: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_0025: pop + IL_0026: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_1' + IL_002b: dup + IL_002c: brtrue.s IL_0045 + + IL_002e: pop + IL_002f: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_0034: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_1'() + IL_003a: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_003f: dup + IL_0040: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_1' + IL_0045: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_004a: pop + IL_004b: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_2' + IL_0050: dup + IL_0051: brtrue.s IL_006a + + IL_0053: pop + IL_0054: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_0059: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_2'() + IL_005f: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_0064: dup + IL_0065: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_2' + IL_006a: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_006f: pop + IL_0070: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_3' + IL_0075: dup + IL_0076: brtrue.s IL_008f + + IL_0078: pop + IL_0079: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_007e: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_3'() + IL_0084: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_0089: dup + IL_008a: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_3' + IL_008f: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_0094: pop + IL_0095: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_4' + IL_009a: dup + IL_009b: brtrue.s IL_00b4 + + IL_009d: pop + IL_009e: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_00a3: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_4'() + IL_00a9: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_00ae: dup + IL_00af: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_4' + IL_00b4: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_00b9: pop + IL_00ba: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_5' + IL_00bf: dup + IL_00c0: brtrue.s IL_00d9 + + IL_00c2: pop + IL_00c3: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_00c8: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_5'() + IL_00ce: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_00d3: dup + IL_00d4: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_5' + IL_00d9: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_00de: pop + IL_00df: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_6' + IL_00e4: dup + IL_00e5: brtrue.s IL_00fe + + IL_00e7: pop + IL_00e8: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_00ed: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_6'() + IL_00f3: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_00f8: dup + IL_00f9: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_6' + IL_00fe: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_0103: pop + IL_0104: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_7' + IL_0109: dup + IL_010a: brtrue.s IL_0123 + + IL_010c: pop + IL_010d: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_0112: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_7'() + IL_0118: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_011d: dup + IL_011e: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_7' + IL_0123: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_0128: pop + IL_0129: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_8' + IL_012e: dup + IL_012f: brtrue.s IL_0148 + + IL_0131: pop + IL_0132: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_0137: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_8'() + IL_013d: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_0142: dup + IL_0143: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_8' + IL_0148: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_014d: pop + IL_014e: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_9' + IL_0153: dup + IL_0154: brtrue.s IL_016d + + IL_0156: pop + IL_0157: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_015c: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_9'() + IL_0162: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_0167: dup + IL_0168: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_9' + IL_016d: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_0172: pop + IL_0173: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_10' + IL_0178: dup + IL_0179: brtrue.s IL_0192 + + IL_017b: pop + IL_017c: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_0181: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_10'() + IL_0187: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_018c: dup + IL_018d: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_10' + IL_0192: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_0197: pop + IL_0198: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_11' + IL_019d: dup + IL_019e: brtrue.s IL_01b7 + + IL_01a0: pop + IL_01a1: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_01a6: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_11'() + IL_01ac: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_01b1: dup + IL_01b2: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_11' + IL_01b7: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_01bc: pop + IL_01bd: ldc.i4.s 100 + IL_01bf: stloc.0 + IL_01c0: br.s IL_01c2 + + IL_01c2: ldloc.0 + IL_01c3: ret + } // end of method VirtualStaticMethodReabstraction::Main + + .method private hidebysig static void Call<(VirtualStaticMethodReabstraction/IFoo) T>() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: constrained. !!T + IL_0006: call void VirtualStaticMethodReabstraction/IFoo::Frob() + IL_000b: nop + IL_000c: ret + } // end of method VirtualStaticMethodReabstraction::Call + + .method private hidebysig static void Call<(VirtualStaticMethodReabstraction/IFoo) T,U>() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: constrained. !!T + IL_0006: call void VirtualStaticMethodReabstraction/IFoo::Frob() + IL_000b: nop + IL_000c: ret + } // end of method VirtualStaticMethodReabstraction::Call + + .method private hidebysig static class [System.Runtime]System.Action + GetAction<(VirtualStaticMethodReabstraction/IFoo) T>() cil managed + { + // Code size 34 (0x22) + .maxstack 8 + IL_0000: ldsfld class [System.Runtime]System.Action class VirtualStaticMethodReabstraction/'O__3_0`1'::'<0>__Frob' + IL_0005: dup + IL_0006: brtrue.s IL_0021 + + IL_0008: pop + IL_0009: ldnull + IL_000a: constrained. !!T + IL_0010: ldftn void VirtualStaticMethodReabstraction/IFoo::Frob() + IL_0016: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_001b: dup + IL_001c: stsfld class [System.Runtime]System.Action class VirtualStaticMethodReabstraction/'O__3_0`1'::'<0>__Frob' + IL_0021: ret + } // end of method VirtualStaticMethodReabstraction::GetAction + + .method private hidebysig static class [System.Runtime]System.Action + GetAction<(VirtualStaticMethodReabstraction/IFoo) T,U>() cil managed + { + // Code size 34 (0x22) + .maxstack 8 + IL_0000: ldsfld class [System.Runtime]System.Action class VirtualStaticMethodReabstraction/'O__4_0`2'::'<0>__Frob' + IL_0005: dup + IL_0006: brtrue.s IL_0021 + + IL_0008: pop + IL_0009: ldnull + IL_000a: constrained. !!T + IL_0010: ldftn void VirtualStaticMethodReabstraction/IFoo::Frob() + IL_0016: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_001b: dup + IL_001c: stsfld class [System.Runtime]System.Action class VirtualStaticMethodReabstraction/'O__4_0`2'::'<0>__Frob' + IL_0021: ret + } // end of method VirtualStaticMethodReabstraction::GetAction + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [System.Runtime]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method VirtualStaticMethodReabstraction::.ctor + +} // end of class VirtualStaticMethodReabstraction + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/src/tests/Loader/classloader/StaticVirtualMethods/NegativeTestCases/AmbiguousImplementationException.ilproj b/src/tests/Loader/classloader/StaticVirtualMethods/NegativeTestCases/AmbiguousImplementationException.ilproj new file mode 100644 index 00000000000000..20e842acc5c82e --- /dev/null +++ b/src/tests/Loader/classloader/StaticVirtualMethods/NegativeTestCases/AmbiguousImplementationException.ilproj @@ -0,0 +1,11 @@ + + + Exe + + + Full + + + + + diff --git a/src/tests/Loader/classloader/StaticVirtualMethods/Reabstraction/Reabstraction.cs b/src/tests/Loader/classloader/StaticVirtualMethods/Reabstraction/Reabstraction.cs new file mode 100644 index 00000000000000..543974778e0b66 --- /dev/null +++ b/src/tests/Loader/classloader/StaticVirtualMethods/Reabstraction/Reabstraction.cs @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +// This is the C# skeleton that was used to build Reabstraction.il. +// The only difference is to change the BarClass and BarStruct types +// to implement IBaz instead of IBar + +using System; +using Xunit; + +class VirtualStaticMethodReabstraction +{ + static int Main() + { + Assert.Throws(() => { Call(); }); + Assert.Throws(() => { Call(); }); + Assert.Throws(() => { Call(); }); + Assert.Throws(() => { Call(); }); + Assert.Throws(() => { Call(); }); + Assert.Throws(() => { Call(); }); + + Assert.Throws(() => { GetAction()(); }); + Assert.Throws(() => { GetAction()(); }); + Assert.Throws(() => { GetAction()(); }); + Assert.Throws(() => { GetAction()(); }); + Assert.Throws(() => { GetAction()(); }); + Assert.Throws(() => { GetAction()(); }); + + return 100; + } + + static void Call() where T : IFoo => T.Frob(); + static void Call() where T : IFoo => T.Frob(); + + static Action GetAction() where T : IFoo => T.Frob; + static Action GetAction() where T : IFoo => T.Frob; + + interface IFoo + { + static virtual void Frob() => throw null; + static virtual void Frob() => throw null; + } + + interface IBar : IFoo + { + static void IFoo.Frob() => throw null; + static void IFoo.Frob() => throw null; + } + + interface IBaz : IFoo + { + static abstract void IFoo.Frob(); + static abstract void IFoo.Frob(); + } + + class BarClass : IBar + { + } + + struct BarStruct : IBar + { + } +} diff --git a/src/tests/Loader/classloader/StaticVirtualMethods/Reabstraction/Reabstraction.il b/src/tests/Loader/classloader/StaticVirtualMethods/Reabstraction/Reabstraction.il new file mode 100644 index 00000000000000..97e4d85073c52e --- /dev/null +++ b/src/tests/Loader/classloader/StaticVirtualMethods/Reabstraction/Reabstraction.il @@ -0,0 +1,579 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + + +// .NET IL Disassembler. Version 8.0.0-dev + + + +// Metadata version: v4.0.30319 +.assembly extern System.Runtime +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....: + .ver 8:0:0:0 +} +.assembly extern xunit.assert +{ + .publickeytoken = (8D 05 B1 BB 7A 6F DB 6C ) // ....zo.l + .ver 2:4:2:0 +} +.assembly Reabstraction +{ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) + .custom instance void [System.Runtime]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + + // --- The following custom attribute is added automatically, do not uncomment ------- + // .custom instance void [System.Runtime]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 ) + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module Reabstraction.dll +// MVID: {b8407d43-f3f1-4afa-9216-253e1c35c868} +.custom instance void [System.Runtime]System.Runtime.CompilerServices.RefSafetyRulesAttribute::.ctor(int32) = ( 01 00 0B 00 00 00 00 00 ) +.imagebase 0x00400000 +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 // WINDOWS_CUI +.corflags 0x00000001 // ILONLY +// Image base: 0x0000022EC3B10000 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class private auto ansi beforefieldinit VirtualStaticMethodReabstraction + extends [System.Runtime]System.Object +{ + .class interface abstract auto ansi nested private IFoo + { + .method public hidebysig static virtual + void Frob() cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: throw + } // end of method IFoo::Frob + + .method public hidebysig static virtual + void Frob() cil managed + { + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: throw + } // end of method IFoo::Frob + + } // end of class IFoo + + .class interface abstract auto ansi nested private IBar + implements VirtualStaticMethodReabstraction/IFoo + { + .method private hidebysig static void + VirtualStaticMethodReabstraction.IFoo.Frob() cil managed + { + .override VirtualStaticMethodReabstraction/IFoo::Frob + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: throw + } // end of method IBar::VirtualStaticMethodReabstraction.IFoo.Frob + + .method private hidebysig static void + VirtualStaticMethodReabstraction.IFoo.Frob() cil managed + { + .override VirtualStaticMethodReabstraction/IFoo::Frob + // Code size 2 (0x2) + .maxstack 8 + IL_0000: ldnull + IL_0001: throw + } // end of method IBar::VirtualStaticMethodReabstraction.IFoo.Frob + + } // end of class IBar + + .class interface abstract auto ansi nested private IBaz + implements VirtualStaticMethodReabstraction/IFoo + { + .method private hidebysig static abstract virtual final + void VirtualStaticMethodReabstraction.IFoo.Frob() cil managed + { + .override VirtualStaticMethodReabstraction/IFoo::Frob + } // end of method IBaz::VirtualStaticMethodReabstraction.IFoo.Frob + + .method private hidebysig static abstract virtual final + void VirtualStaticMethodReabstraction.IFoo.Frob() cil managed + { + .override VirtualStaticMethodReabstraction/IFoo::Frob + } // end of method IBaz::VirtualStaticMethodReabstraction.IFoo.Frob + + } // end of class IBaz + + .class auto ansi nested private beforefieldinit BarClass + extends [System.Runtime]System.Object + implements VirtualStaticMethodReabstraction/IBaz, + VirtualStaticMethodReabstraction/IFoo + { + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [System.Runtime]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method BarClass::.ctor + + } // end of class BarClass + + .class sequential ansi sealed nested private beforefieldinit BarStruct + extends [System.Runtime]System.ValueType + implements VirtualStaticMethodReabstraction/IBaz, + VirtualStaticMethodReabstraction/IFoo + { + .pack 0 + .size 1 + } // end of class BarStruct + + .class auto ansi serializable sealed nested private beforefieldinit '<>c' + extends [System.Runtime]System.Object + { + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public static initonly class VirtualStaticMethodReabstraction/'<>c' '<>9' + .field public static class [System.Runtime]System.Action '<>9__0_0' + .field public static class [System.Runtime]System.Action '<>9__0_1' + .field public static class [System.Runtime]System.Action '<>9__0_2' + .field public static class [System.Runtime]System.Action '<>9__0_3' + .field public static class [System.Runtime]System.Action '<>9__0_4' + .field public static class [System.Runtime]System.Action '<>9__0_5' + .field public static class [System.Runtime]System.Action '<>9__0_6' + .field public static class [System.Runtime]System.Action '<>9__0_7' + .field public static class [System.Runtime]System.Action '<>9__0_8' + .field public static class [System.Runtime]System.Action '<>9__0_9' + .field public static class [System.Runtime]System.Action '<>9__0_10' + .field public static class [System.Runtime]System.Action '<>9__0_11' + .method private hidebysig specialname rtspecialname static + void .cctor() cil managed + { + // Code size 11 (0xb) + .maxstack 8 + IL_0000: newobj instance void VirtualStaticMethodReabstraction/'<>c'::.ctor() + IL_0005: stsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_000a: ret + } // end of method '<>c'::.cctor + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [System.Runtime]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::.ctor + + .method assembly hidebysig instance void + '
b__0_0'() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: nop + IL_0001: call void VirtualStaticMethodReabstraction::Call() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::'
b__0_0' + + .method assembly hidebysig instance void + '
b__0_1'() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: nop + IL_0001: call void VirtualStaticMethodReabstraction::Call() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::'
b__0_1' + + .method assembly hidebysig instance void + '
b__0_2'() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: nop + IL_0001: call void VirtualStaticMethodReabstraction::Call() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::'
b__0_2' + + .method assembly hidebysig instance void + '
b__0_3'() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: nop + IL_0001: call void VirtualStaticMethodReabstraction::Call() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::'
b__0_3' + + .method assembly hidebysig instance void + '
b__0_4'() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: nop + IL_0001: call void VirtualStaticMethodReabstraction::Call() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::'
b__0_4' + + .method assembly hidebysig instance void + '
b__0_5'() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: nop + IL_0001: call void VirtualStaticMethodReabstraction::Call() + IL_0006: nop + IL_0007: ret + } // end of method '<>c'::'
b__0_5' + + .method assembly hidebysig instance void + '
b__0_6'() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: nop + IL_0001: call class [System.Runtime]System.Action VirtualStaticMethodReabstraction::GetAction() + IL_0006: callvirt instance void [System.Runtime]System.Action::Invoke() + IL_000b: nop + IL_000c: ret + } // end of method '<>c'::'
b__0_6' + + .method assembly hidebysig instance void + '
b__0_7'() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: nop + IL_0001: call class [System.Runtime]System.Action VirtualStaticMethodReabstraction::GetAction() + IL_0006: callvirt instance void [System.Runtime]System.Action::Invoke() + IL_000b: nop + IL_000c: ret + } // end of method '<>c'::'
b__0_7' + + .method assembly hidebysig instance void + '
b__0_8'() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: nop + IL_0001: call class [System.Runtime]System.Action VirtualStaticMethodReabstraction::GetAction() + IL_0006: callvirt instance void [System.Runtime]System.Action::Invoke() + IL_000b: nop + IL_000c: ret + } // end of method '<>c'::'
b__0_8' + + .method assembly hidebysig instance void + '
b__0_9'() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: nop + IL_0001: call class [System.Runtime]System.Action VirtualStaticMethodReabstraction::GetAction() + IL_0006: callvirt instance void [System.Runtime]System.Action::Invoke() + IL_000b: nop + IL_000c: ret + } // end of method '<>c'::'
b__0_9' + + .method assembly hidebysig instance void + '
b__0_10'() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: nop + IL_0001: call class [System.Runtime]System.Action VirtualStaticMethodReabstraction::GetAction() + IL_0006: callvirt instance void [System.Runtime]System.Action::Invoke() + IL_000b: nop + IL_000c: ret + } // end of method '<>c'::'
b__0_10' + + .method assembly hidebysig instance void + '
b__0_11'() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: nop + IL_0001: call class [System.Runtime]System.Action VirtualStaticMethodReabstraction::GetAction() + IL_0006: callvirt instance void [System.Runtime]System.Action::Invoke() + IL_000b: nop + IL_000c: ret + } // end of method '<>c'::'
b__0_11' + + } // end of class '<>c' + + .class abstract auto ansi sealed nested private beforefieldinit 'O__3_0`1'<(VirtualStaticMethodReabstraction/IFoo) T> + extends [System.Runtime]System.Object + { + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public static class [System.Runtime]System.Action '<0>__Frob' + } // end of class 'O__3_0`1' + + .class abstract auto ansi sealed nested private beforefieldinit 'O__4_0`2'<(VirtualStaticMethodReabstraction/IFoo) T,U> + extends [System.Runtime]System.Object + { + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public static class [System.Runtime]System.Action '<0>__Frob' + } // end of class 'O__4_0`2' + + .method private hidebysig static int32 + Main() cil managed + { + .entrypoint + // Code size 452 (0x1c4) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: nop + IL_0001: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_0' + IL_0006: dup + IL_0007: brtrue.s IL_0020 + + IL_0009: pop + IL_000a: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_000f: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_0'() + IL_0015: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_001a: dup + IL_001b: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_0' + IL_0020: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_0025: pop + IL_0026: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_1' + IL_002b: dup + IL_002c: brtrue.s IL_0045 + + IL_002e: pop + IL_002f: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_0034: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_1'() + IL_003a: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_003f: dup + IL_0040: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_1' + IL_0045: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_004a: pop + IL_004b: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_2' + IL_0050: dup + IL_0051: brtrue.s IL_006a + + IL_0053: pop + IL_0054: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_0059: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_2'() + IL_005f: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_0064: dup + IL_0065: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_2' + IL_006a: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_006f: pop + IL_0070: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_3' + IL_0075: dup + IL_0076: brtrue.s IL_008f + + IL_0078: pop + IL_0079: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_007e: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_3'() + IL_0084: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_0089: dup + IL_008a: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_3' + IL_008f: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_0094: pop + IL_0095: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_4' + IL_009a: dup + IL_009b: brtrue.s IL_00b4 + + IL_009d: pop + IL_009e: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_00a3: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_4'() + IL_00a9: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_00ae: dup + IL_00af: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_4' + IL_00b4: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_00b9: pop + IL_00ba: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_5' + IL_00bf: dup + IL_00c0: brtrue.s IL_00d9 + + IL_00c2: pop + IL_00c3: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_00c8: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_5'() + IL_00ce: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_00d3: dup + IL_00d4: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_5' + IL_00d9: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_00de: pop + IL_00df: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_6' + IL_00e4: dup + IL_00e5: brtrue.s IL_00fe + + IL_00e7: pop + IL_00e8: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_00ed: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_6'() + IL_00f3: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_00f8: dup + IL_00f9: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_6' + IL_00fe: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_0103: pop + IL_0104: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_7' + IL_0109: dup + IL_010a: brtrue.s IL_0123 + + IL_010c: pop + IL_010d: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_0112: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_7'() + IL_0118: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_011d: dup + IL_011e: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_7' + IL_0123: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_0128: pop + IL_0129: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_8' + IL_012e: dup + IL_012f: brtrue.s IL_0148 + + IL_0131: pop + IL_0132: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_0137: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_8'() + IL_013d: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_0142: dup + IL_0143: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_8' + IL_0148: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_014d: pop + IL_014e: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_9' + IL_0153: dup + IL_0154: brtrue.s IL_016d + + IL_0156: pop + IL_0157: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_015c: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_9'() + IL_0162: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_0167: dup + IL_0168: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_9' + IL_016d: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_0172: pop + IL_0173: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_10' + IL_0178: dup + IL_0179: brtrue.s IL_0192 + + IL_017b: pop + IL_017c: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_0181: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_10'() + IL_0187: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_018c: dup + IL_018d: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_10' + IL_0192: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_0197: pop + IL_0198: ldsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_11' + IL_019d: dup + IL_019e: brtrue.s IL_01b7 + + IL_01a0: pop + IL_01a1: ldsfld class VirtualStaticMethodReabstraction/'<>c' VirtualStaticMethodReabstraction/'<>c'::'<>9' + IL_01a6: ldftn instance void VirtualStaticMethodReabstraction/'<>c'::'
b__0_11'() + IL_01ac: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_01b1: dup + IL_01b2: stsfld class [System.Runtime]System.Action VirtualStaticMethodReabstraction/'<>c'::'<>9__0_11' + IL_01b7: call !!0 [xunit.assert]Xunit.Assert::Throws(class [System.Runtime]System.Action) + IL_01bc: pop + IL_01bd: ldc.i4.s 100 + IL_01bf: stloc.0 + IL_01c0: br.s IL_01c2 + + IL_01c2: ldloc.0 + IL_01c3: ret + } // end of method VirtualStaticMethodReabstraction::Main + + .method private hidebysig static void Call<(VirtualStaticMethodReabstraction/IFoo) T>() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: constrained. !!T + IL_0006: call void VirtualStaticMethodReabstraction/IFoo::Frob() + IL_000b: nop + IL_000c: ret + } // end of method VirtualStaticMethodReabstraction::Call + + .method private hidebysig static void Call<(VirtualStaticMethodReabstraction/IFoo) T,U>() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: constrained. !!T + IL_0006: call void VirtualStaticMethodReabstraction/IFoo::Frob() + IL_000b: nop + IL_000c: ret + } // end of method VirtualStaticMethodReabstraction::Call + + .method private hidebysig static class [System.Runtime]System.Action + GetAction<(VirtualStaticMethodReabstraction/IFoo) T>() cil managed + { + // Code size 34 (0x22) + .maxstack 8 + IL_0000: ldsfld class [System.Runtime]System.Action class VirtualStaticMethodReabstraction/'O__3_0`1'::'<0>__Frob' + IL_0005: dup + IL_0006: brtrue.s IL_0021 + + IL_0008: pop + IL_0009: ldnull + IL_000a: constrained. !!T + IL_0010: ldftn void VirtualStaticMethodReabstraction/IFoo::Frob() + IL_0016: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_001b: dup + IL_001c: stsfld class [System.Runtime]System.Action class VirtualStaticMethodReabstraction/'O__3_0`1'::'<0>__Frob' + IL_0021: ret + } // end of method VirtualStaticMethodReabstraction::GetAction + + .method private hidebysig static class [System.Runtime]System.Action + GetAction<(VirtualStaticMethodReabstraction/IFoo) T,U>() cil managed + { + // Code size 34 (0x22) + .maxstack 8 + IL_0000: ldsfld class [System.Runtime]System.Action class VirtualStaticMethodReabstraction/'O__4_0`2'::'<0>__Frob' + IL_0005: dup + IL_0006: brtrue.s IL_0021 + + IL_0008: pop + IL_0009: ldnull + IL_000a: constrained. !!T + IL_0010: ldftn void VirtualStaticMethodReabstraction/IFoo::Frob() + IL_0016: newobj instance void [System.Runtime]System.Action::.ctor(object, + native int) + IL_001b: dup + IL_001c: stsfld class [System.Runtime]System.Action class VirtualStaticMethodReabstraction/'O__4_0`2'::'<0>__Frob' + IL_0021: ret + } // end of method VirtualStaticMethodReabstraction::GetAction + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [System.Runtime]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method VirtualStaticMethodReabstraction::.ctor + +} // end of class VirtualStaticMethodReabstraction + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** diff --git a/src/tests/Loader/classloader/StaticVirtualMethods/Reabstraction/Reabstraction.ilproj b/src/tests/Loader/classloader/StaticVirtualMethods/Reabstraction/Reabstraction.ilproj new file mode 100644 index 00000000000000..62d12363e685f8 --- /dev/null +++ b/src/tests/Loader/classloader/StaticVirtualMethods/Reabstraction/Reabstraction.ilproj @@ -0,0 +1,12 @@ + + + Exe + true + + + Full + + + + + diff --git a/src/tests/issues.targets b/src/tests/issues.targets index 4c6f7cb1b00403..a97866b950e27b 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -1251,6 +1251,9 @@ + + https://github.com/dotnet/runtime/issues/88775 + https://github.com/dotnet/runtime/issues/88689