未验证 提交 96ef47b2 编写于 作者: M Michal Strehovský 提交者: GitHub

Include method instantiation MethodTables in compilation (#66984)

* Include method instantiation MethodTables in compilation

We'll need to load the `MethodTable` so that we can search for it in GVM tables.

* Regression test
上级 970a7e2d
......@@ -253,7 +253,9 @@ private IEnumerable<DependencyListEntry> GetGenericVirtualMethodDependencies(Nod
{
var dependencies = (DependencyList)base.GetStaticDependencies(factory);
dependencies.Add(factory.GVMDependencies(_method.GetCanonMethodTarget(CanonicalFormKind.Specific)), "Potential generic virtual method call");
MethodDesc canonMethod = _method.GetCanonMethodTarget(CanonicalFormKind.Specific);
dependencies.Add(factory.GVMDependencies(canonMethod), "Potential generic virtual method call");
// Variant generic virtual method calls at runtime might need to build the concrete version of the
// type we could be dispatching on to find the appropriate GVM entry.
......@@ -262,6 +264,11 @@ private IEnumerable<DependencyListEntry> GetGenericVirtualMethodDependencies(Nod
GenericTypesTemplateMap.GetTemplateTypeDependencies(ref dependencies, factory, _method.OwningType.ConvertToCanonForm(CanonicalFormKind.Specific));
}
foreach (TypeDesc instArg in canonMethod.Instantiation)
{
dependencies.Add(factory.MaximallyConstructableType(instArg), "Type we need to look up for GVM dispatch");
}
return dependencies;
}
......
......@@ -44,6 +44,7 @@ internal static int Run()
TestGenericRecursionFromNpgsql.Run();
TestRecursionInGenericVirtualMethods.Run();
TestRecursionThroughGenericLookups.Run();
TestGvmLookupDependency.Run();
#if !CODEGEN_CPP
TestNullableCasting.Run();
TestVariantCasting.Run();
......@@ -3147,4 +3148,24 @@ public static void Run()
new RangeHandler<object>().Write(default);
}
}
static class TestGvmLookupDependency
{
struct SmallCat<T> { }
interface ITechnique
{
void CatSlaps<T>() { /* Cannot reference T or it stops testing the thing it should */ }
}
struct Technique : ITechnique { }
static void CatConcepts<T, U>() where T : ITechnique => default(T).CatSlaps<SmallCat<U>>();
public static void Run()
{
CatConcepts<Technique, int>();
CatConcepts<Technique, object>();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册