File tree 2 files changed +29
-1
lines changed
coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis
tests/nativeaot/SmokeTests/UnitTests
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -253,7 +253,9 @@ private IEnumerable<DependencyListEntry> GetGenericVirtualMethodDependencies(Nod
253
253
{
254
254
var dependencies = ( DependencyList ) base . GetStaticDependencies ( factory ) ;
255
255
256
- dependencies . Add ( factory . GVMDependencies ( _method . GetCanonMethodTarget ( CanonicalFormKind . Specific ) ) , "Potential generic virtual method call" ) ;
256
+ MethodDesc canonMethod = _method . GetCanonMethodTarget ( CanonicalFormKind . Specific ) ;
257
+
258
+ dependencies . Add ( factory . GVMDependencies ( canonMethod ) , "Potential generic virtual method call" ) ;
257
259
258
260
// Variant generic virtual method calls at runtime might need to build the concrete version of the
259
261
// type we could be dispatching on to find the appropriate GVM entry.
@@ -262,6 +264,11 @@ private IEnumerable<DependencyListEntry> GetGenericVirtualMethodDependencies(Nod
262
264
GenericTypesTemplateMap . GetTemplateTypeDependencies ( ref dependencies , factory , _method . OwningType . ConvertToCanonForm ( CanonicalFormKind . Specific ) ) ;
263
265
}
264
266
267
+ foreach ( TypeDesc instArg in canonMethod . Instantiation )
268
+ {
269
+ dependencies . Add ( factory . MaximallyConstructableType ( instArg ) , "Type we need to look up for GVM dispatch" ) ;
270
+ }
271
+
265
272
return dependencies ;
266
273
}
267
274
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ internal static int Run()
44
44
TestGenericRecursionFromNpgsql . Run ( ) ;
45
45
TestRecursionInGenericVirtualMethods . Run ( ) ;
46
46
TestRecursionThroughGenericLookups . Run ( ) ;
47
+ TestGvmLookupDependency . Run ( ) ;
47
48
#if ! CODEGEN_CPP
48
49
TestNullableCasting . Run ( ) ;
49
50
TestVariantCasting . Run ( ) ;
@@ -3147,4 +3148,24 @@ public static void Run()
3147
3148
new RangeHandler < object > ( ) . Write ( default ) ;
3148
3149
}
3149
3150
}
3151
+
3152
+ static class TestGvmLookupDependency
3153
+ {
3154
+ struct SmallCat < T > { }
3155
+
3156
+ interface ITechnique
3157
+ {
3158
+ void CatSlaps < T > ( ) { /* Cannot reference T or it stops testing the thing it should */ }
3159
+ }
3160
+
3161
+ struct Technique : ITechnique { }
3162
+
3163
+ static void CatConcepts < T , U > ( ) where T : ITechnique => default ( T ) . CatSlaps < SmallCat < U > > ( ) ;
3164
+
3165
+ public static void Run ( )
3166
+ {
3167
+ CatConcepts < Technique , int > ( ) ;
3168
+ CatConcepts < Technique , object > ( ) ;
3169
+ }
3170
+ }
3150
3171
}
You can’t perform that action at this time.
0 commit comments