summaryrefslogtreecommitdiff
path: root/tests/src/JIT/opt/Enum/shared.cs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/JIT/opt/Enum/shared.cs')
-rw-r--r--tests/src/JIT/opt/Enum/shared.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/src/JIT/opt/Enum/shared.cs b/tests/src/JIT/opt/Enum/shared.cs
new file mode 100644
index 0000000000..f15361a05a
--- /dev/null
+++ b/tests/src/JIT/opt/Enum/shared.cs
@@ -0,0 +1,41 @@
+// 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.
+
+// Some simple tests for the Enum.HasFlag optimization.
+// Verify the optimization avoids firing for shared types.
+
+using System;
+using System.Runtime.CompilerServices;
+
+class MyG<T,U>
+{
+ public enum A
+ {
+ X = 1
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static void foo()
+ {
+ var a = MyG<object,U>.A.X;
+ a.HasFlag(MyG<T,string>.A.X);
+ }
+}
+
+class My
+{
+ public static int Main()
+ {
+ int result = 0;
+ try
+ {
+ MyG<My,My>.foo();
+ }
+ catch(ArgumentException)
+ {
+ result = 100;
+ }
+ return result;
+ }
+}