Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/coreclr/vm/methodtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5588,9 +5588,11 @@ namespace
FALSE, // forceBoxedEntryPoint
candidateMaybe->HasMethodInstantiation() ?
candidateMaybe->AsInstantiatedMethodDesc()->IMD_GetMethodInstantiation() :
Instantiation(), // for method themselves that are generic
Instantiation(), // for method themselves that are generic
FALSE, // allowInstParam
TRUE // forceRemoteableMethod
TRUE, // forceRemoteableMethod
TRUE, // allowCreate
CLASS_LOAD_EXACTPARENTS // level
);
}

Expand Down Expand Up @@ -8239,7 +8241,7 @@ MethodTable::TryResolveVirtualStaticMethodOnThisType(MethodTable* pInterfaceType
/* allowInstParam */ FALSE,
/* forceRemotableMethod */ FALSE,
/* allowCreate */ TRUE,
/* level */ CLASS_LOADED);
/* level */ CLASS_LOAD_EXACTPARENTS);
}
if (pMethodImpl != nullptr)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;

interface IBase<T>
{
public static abstract void Method();
}

interface IDerived<T> : IBase<T>
{
public static void IBase<T>.Method()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the public in this line is redundant and causing compilation to fail.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your feedback, I have removed the public modifier from both interfaces in the 2nd commit. Please note that the C# code is actually not used for building the test - that's why it has the 'template' extension - because we don't yet have a Roslyn capable of compiling this code, the actual test source code is written in IL.

{
Console.WriteLine("IDerived.Method");
}
}

class Final : IDerived<Final>
{
}

class Program
{
private static void CallSVM<T, U>()
where T : IBase<U>
{
T.Method();
}

static int Main()
{
CallSVM<Final, Final>();
return 100;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@

// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.18408
// Copyright (c) Microsoft Corporation. All rights reserved.



// Metadata version: v4.0.30319
.assembly extern System.Runtime
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
.ver 7:0:0:0
}
.assembly extern System.Console
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
.ver 7:0:0:0
}
.assembly RecursiveGeneric
{
.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.

//
// .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 RecursiveGeneric.dll
// MVID: {10541B0F-16D6-4F9A-B0EB-E793F524F163}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x03000000


// =============== CLASS MEMBERS DECLARATION ===================

.class interface private abstract auto ansi IBase`1<T>
{
.method public hidebysig static abstract virtual
void Method() cil managed
{
} // end of method IBase`1::Method

} // end of class IBase`1

.class interface private abstract auto ansi IDerived`1<T>
implements class IBase`1<!T>
{
.method public hidebysig static void Method() cil managed
{
.override method void class IBase`1<!T>::Method()
//
.maxstack 8
IL_0000: nop
IL_0001: ldstr "Final.Method"
IL_0006: call void [System.Console]System.Console::WriteLine(string)
IL_000b: nop
IL_000c: ret
} // end of method Final::Method

} // end of class IDerived`1

.class private auto ansi beforefieldinit Final
extends [System.Runtime]System.Object
implements class IDerived`1<class Final>,
class IBase`1<class Final>
{
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
//
.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 Final::.ctor

} // end of class Final

.class private auto ansi beforefieldinit Program
extends [System.Runtime]System.Object
{
.method private hidebysig static void CallSVM<(class IBase`1<!!U>) T,U>() cil managed
{
//
.maxstack 8
IL_0000: nop
IL_0001: constrained. !!T
IL_0007: call void class IBase`1<!!U>::Method()
IL_000c: nop
IL_000d: ret
} // end of method Program::CallSVM

.method private hidebysig static int32
Main() cil managed
{
.entrypoint
//
.maxstack 1
.locals init ([0] int32 V_0)
IL_0000: nop
IL_0001: call void Program::CallSVM<class Final,class Final>()
IL_0006: nop
IL_0007: ldc.i4.s 100
IL_0009: stloc.0
IL_000a: br.s IL_000c

IL_000c: ldloc.0
IL_000d: ret
} // end of method Program::Main

.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
//
.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 Program::.ctor

} // end of class Program


// =============================================================

//
//
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>Full</DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileName).il" />
</ItemGroup>
</Project>