Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>2016-11-12 22:34:06 +0300
committerJan Kotas <jkotas@microsoft.com>2016-11-12 22:34:06 +0300
commit77d17f08abfe27d43760b2321376a99fdb5a00fb (patch)
treee6177b5232dc81d36986ac63cbb4803436ff55db /tests/src/Simple/Generics/Generics.cs
parentbac545bdb0a00d0033143360991c1aa1a1110d7b (diff)
Fix walking base hierarchy when computing dictionary slots (#2193)
When the generic ready to run lookup helper needs to know the generic dictionary vtable slot, it passes the canonical type to the helper that determines the slot. `GetNumberOfBaseSlots` needs to be able to deal with this, and the fact that the slots might be lazily determined. Converting to canon fixes this due to how we ensure canonically equivalent types have the same vtable in #2096. The other option would be to back out that change and completely revamp how we do lazy slots for generic types. I found this when I ran the reflection invoke test with shared generics enabled.
Diffstat (limited to 'tests/src/Simple/Generics/Generics.cs')
-rw-r--r--tests/src/Simple/Generics/Generics.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/src/Simple/Generics/Generics.cs b/tests/src/Simple/Generics/Generics.cs
index 033c1d28c..b88239695 100644
--- a/tests/src/Simple/Generics/Generics.cs
+++ b/tests/src/Simple/Generics/Generics.cs
@@ -13,6 +13,7 @@ class Program
TestInitThisClass.Run();
TestDelegateFatFunctionPointers.Run();
TestVirtualMethodUseTracking.Run();
+ TestSlotsInHierarchy.Run();
TestNameManglingCollisionRegression.Run();
return 100;
@@ -226,6 +227,42 @@ class Program
}
}
+ /// <summary>
+ /// Makes sure that during the base slot computation for types such as
+ /// Derived&lt;__Canon&gt; (where the base type ends up being Base&lt;__Canon, string&gt;),
+ /// the lazy vtable slot computation works.
+ /// </summary>
+ class TestSlotsInHierarchy
+ {
+ class Base<T, U>
+ {
+ public virtual int Do()
+ {
+ return 42;
+ }
+ }
+
+ class Derived<T> : Base<T, string> where T : class
+ {
+ public T Cast(object v)
+ {
+ return v as T;
+ }
+ }
+
+ public static void Run()
+ {
+ var derived = new Derived<string>();
+ var derivedAsBase = (Base<string, string>)derived;
+
+ if (derivedAsBase.Do() != 42)
+ throw new Exception();
+
+ if (derived.Cast("Hello") != "Hello")
+ throw new Exception();
+ }
+ }
+
//
// Regression test for issue https://github.com/dotnet/corert/issues/1964
//