summaryrefslogtreecommitdiff
path: root/tests/src/JIT/opt/Devirtualization/box1.cs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/JIT/opt/Devirtualization/box1.cs')
-rw-r--r--tests/src/JIT/opt/Devirtualization/box1.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/src/JIT/opt/Devirtualization/box1.cs b/tests/src/JIT/opt/Devirtualization/box1.cs
new file mode 100644
index 0000000000..51121f37d8
--- /dev/null
+++ b/tests/src/JIT/opt/Devirtualization/box1.cs
@@ -0,0 +1,29 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+
+interface IPrint
+{
+ void Print();
+}
+
+struct X<T> : IPrint
+{
+ public X(T t) { _t = t; }
+ public void Print() { Console.WriteLine(_t); }
+ T _t;
+}
+
+class Y
+{
+ static int Main()
+ {
+ var s = new X<string>("hello, world!");
+ // Jit should devirtualize, remove box,
+ // change to call unboxed entry, then inline.
+ ((IPrint)s).Print();
+ return 100;
+ }
+}