summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>2019-05-22 15:59:43 -0700
committerGitHub <noreply@github.com>2019-05-22 15:59:43 -0700
commit85e4ce49ecdcfa51d4c1d7fd9ab9b57658ba92fa (patch)
treed826e41510b7e2436ed55c87c4851e6bd13a023e /tests
parent128e5dd19c4a9045e713fa51c290a14bd0019c94 (diff)
downloadcoreclr-85e4ce49ecdcfa51d4c1d7fd9ab9b57658ba92fa.tar.gz
coreclr-85e4ce49ecdcfa51d4c1d7fd9ab9b57658ba92fa.tar.bz2
coreclr-85e4ce49ecdcfa51d4c1d7fd9ab9b57658ba92fa.zip
Allow CORINFO_BOX_THIS for primitives and enums (#24644)
We abort R2R compiling methods with `thisTransform == CORINFO_BOX_THIS`. This means we don't R2R compile some methods that do virtual calls on valuetypes (e.g. calling `ToString` on a struct that doesn't itself provide a `ToString` method). We can't allow this in general, but enums and primitives should be fine.
Diffstat (limited to 'tests')
-rw-r--r--tests/src/readytorun/tests/main.cs9
-rw-r--r--tests/src/readytorun/tests/test.cs13
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/src/readytorun/tests/main.cs b/tests/src/readytorun/tests/main.cs
index 0223a008a6..bcadc37a3b 100644
--- a/tests/src/readytorun/tests/main.cs
+++ b/tests/src/readytorun/tests/main.cs
@@ -59,6 +59,15 @@ class Program
var iface = (IMyInterface)o;
Assert.AreEqual(iface.InterfaceMethod(" "), "Interface result");
Assert.AreEqual(MyClass.TestInterfaceMethod(iface, "+"), "Interface+result");
+
+ // V2 adds override of ToString
+ if (typeof(MyStructWithVirtuals).GetMethod("ToString").DeclaringType == typeof(MyStructWithVirtuals))
+ {
+ // Make sure the constrained call to ToString doesn't box
+ var mystruct = new MyStructWithVirtuals();
+ mystruct.ToString();
+ Assert.AreEqual(mystruct.X, "Overriden");
+ }
}
static void TestMovedVirtualMethods()
diff --git a/tests/src/readytorun/tests/test.cs b/tests/src/readytorun/tests/test.cs
index 8a6beaea15..508b369bae 100644
--- a/tests/src/readytorun/tests/test.cs
+++ b/tests/src/readytorun/tests/test.cs
@@ -389,6 +389,19 @@ public struct MyChangingHFAStruct
}
}
+public struct MyStructWithVirtuals
+{
+ public string X;
+
+#if V2
+ public override string ToString()
+ {
+ X = "Overriden";
+ return base.ToString();
+ }
+#endif
+}
+
public class ByteBaseClass : List<byte>
{
public byte BaseByte;