2008-05-23 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Fri, 23 May 2008 22:35:45 +0000 (22:35 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Fri, 23 May 2008 22:35:45 +0000 (22:35 -0000)
* valid_contravariant_delegate_1.il
* valid_contravariant_delegate_2.il
* valid_convariant_delegate_1.il
* valid_convariant_delegate_2.il
* valid_generic_delegate_1.cs
* valid_generic_delegate_2.cs
* valid_invariant_delegate.il: Test compatibility of generic
delegates in the presence of variance.

svn path=/trunk/mono/; revision=103963

mono/tests/verifier/ChangeLog
mono/tests/verifier/valid_contravariant_delegate_1.il [new file with mode: 0644]
mono/tests/verifier/valid_contravariant_delegate_2.il [new file with mode: 0644]
mono/tests/verifier/valid_convariant_delegate_1.il [new file with mode: 0644]
mono/tests/verifier/valid_convariant_delegate_2.il [new file with mode: 0644]
mono/tests/verifier/valid_generic_delegate_1.cs [new file with mode: 0644]
mono/tests/verifier/valid_generic_delegate_2.cs [new file with mode: 0644]
mono/tests/verifier/valid_invariant_delegate.il [new file with mode: 0644]

index 70de9a05fbfb12729fd694dedb27de8b38df91da..fa6ee6421e1f5c3d1fb58d34a93d4b6a571e46a4 100644 (file)
@@ -1,3 +1,14 @@
+2008-05-23 Rodrigo Kumpera <rkumpera@novell.com>
+
+       * valid_contravariant_delegate_1.il
+       * valid_contravariant_delegate_2.il
+       * valid_convariant_delegate_1.il
+       * valid_convariant_delegate_2.il
+       * valid_generic_delegate_1.cs
+       * valid_generic_delegate_2.cs
+       * valid_invariant_delegate.il: Test compatibility of generic
+       delegates in the presence of variance.
+
 2008-05-14 Rodrigo Kumpera <rkumpera@novell.com>
 
        * valid_visibility_across_generic_instantiations.cs: Regression
diff --git a/mono/tests/verifier/valid_contravariant_delegate_1.il b/mono/tests/verifier/valid_contravariant_delegate_1.il
new file mode 100644 (file)
index 0000000..a8ac3dd
--- /dev/null
@@ -0,0 +1,71 @@
+.assembly extern mscorlib
+{
+  .ver 2:0:0:0
+  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+}
+.assembly 'valid_generic_delegate_1'
+{
+  .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() =  (
+               01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
+               63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01       ) // ceptionThrows.
+
+  .hash algorithm 0x00008004
+  .ver  0:0:0:0
+}
+.module valid_covariant_delegate.exe // GUID = {D9327351-CCFF-40F3-A80F-810E3C4283A7}
+
+.class interface public auto ansi beforefieldinit Generic<-T>
+{
+
+}
+
+.class public auto ansi beforefieldinit Driver extends [mscorlib]System.Object
+{
+       .method public static hidebysig default !!R Foo<T, R> (!!T arg)  cil managed 
+       {
+               .maxstack 8
+               .locals init (!!R l)
+               ldloca 0
+               initobj !!R
+               ldloc.0
+               ret 
+       }
+
+       .method public static hidebysig default void Main ()  cil managed 
+       {
+               .entrypoint
+               .maxstack 8
+
+               ldnull 
+               ldftn !!1 class Driver::Foo<class Generic<string>, string> (!!0)
+               newobj instance void class Dele`2<class Generic<object>, string>::'.ctor'(object, native int)
+
+               pop 
+               ret 
+       }
+}
+
+  .class public auto ansi sealed Dele`2<T,R>
+       extends [mscorlib]System.MulticastDelegate
+  {
+    .method public hidebysig  specialname  rtspecialname 
+           instance default void '.ctor' (object 'object', native int 'method')  runtime managed 
+    {
+    }
+
+    .method public virtual  hidebysig  newslot 
+           instance default !R Invoke (!T t)  runtime managed 
+    {
+    }
+
+    .method public virtual  hidebysig  newslot 
+           instance default class [mscorlib]System.IAsyncResult BeginInvoke (!T t, class [mscorlib]System.AsyncCallback callback, object 'object')  runtime managed 
+    {
+    }
+
+    .method public virtual  hidebysig  newslot 
+           instance default !R EndInvoke (class [mscorlib]System.IAsyncResult result)  runtime managed 
+    {
+    }
+}
+
diff --git a/mono/tests/verifier/valid_contravariant_delegate_2.il b/mono/tests/verifier/valid_contravariant_delegate_2.il
new file mode 100644 (file)
index 0000000..c2363ba
--- /dev/null
@@ -0,0 +1,71 @@
+.assembly extern mscorlib
+{
+  .ver 2:0:0:0
+  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+}
+.assembly 'valid_generic_delegate_1'
+{
+  .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() =  (
+               01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
+               63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01       ) // ceptionThrows.
+
+  .hash algorithm 0x00008004
+  .ver  0:0:0:0
+}
+.module valid_covariant_delegate.exe // GUID = {D9327351-CCFF-40F3-A80F-810E3C4283A7}
+
+.class interface public auto ansi beforefieldinit Generic<-T>
+{
+
+}
+
+.class public auto ansi beforefieldinit Driver extends [mscorlib]System.Object
+{
+       .method public static hidebysig default !!R Foo<T, R> (!!T arg)  cil managed 
+       {
+               .maxstack 8
+               .locals init (!!R l)
+               ldloca 0
+               initobj !!R
+               ldloc.0
+               ret 
+       }
+
+       .method public static hidebysig default void Main ()  cil managed 
+       {
+               .entrypoint
+               .maxstack 8
+
+               ldnull 
+               ldftn !!1 class Driver::Foo<object, class Generic<object>> (!!0)
+               newobj instance void class Dele`2<object, class Generic<string>>::'.ctor'(object, native int)
+
+               pop 
+               ret 
+       }
+}
+
+  .class public auto ansi sealed Dele`2<T,R>
+       extends [mscorlib]System.MulticastDelegate
+  {
+    .method public hidebysig  specialname  rtspecialname 
+           instance default void '.ctor' (object 'object', native int 'method')  runtime managed 
+    {
+    }
+
+    .method public virtual  hidebysig  newslot 
+           instance default !R Invoke (!T t)  runtime managed 
+    {
+    }
+
+    .method public virtual  hidebysig  newslot 
+           instance default class [mscorlib]System.IAsyncResult BeginInvoke (!T t, class [mscorlib]System.AsyncCallback callback, object 'object')  runtime managed 
+    {
+    }
+
+    .method public virtual  hidebysig  newslot 
+           instance default !R EndInvoke (class [mscorlib]System.IAsyncResult result)  runtime managed 
+    {
+    }
+}
+
diff --git a/mono/tests/verifier/valid_convariant_delegate_1.il b/mono/tests/verifier/valid_convariant_delegate_1.il
new file mode 100644 (file)
index 0000000..a2460e6
--- /dev/null
@@ -0,0 +1,71 @@
+.assembly extern mscorlib
+{
+  .ver 2:0:0:0
+  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+}
+.assembly 'valid_generic_delegate_1'
+{
+  .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() =  (
+               01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
+               63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01       ) // ceptionThrows.
+
+  .hash algorithm 0x00008004
+  .ver  0:0:0:0
+}
+.module valid_covariant_delegate.exe // GUID = {D9327351-CCFF-40F3-A80F-810E3C4283A7}
+
+.class interface public auto ansi beforefieldinit Generic<+T>
+{
+
+}
+
+.class public auto ansi beforefieldinit Driver extends [mscorlib]System.Object
+{
+       .method public static hidebysig default !!R Foo<T, R> (!!T arg)  cil managed 
+       {
+               .maxstack 8
+               .locals init (!!R l)
+               ldloca 0
+               initobj !!R
+               ldloc.0
+               ret 
+       }
+
+       .method public static hidebysig default void Main ()  cil managed 
+       {
+               .entrypoint
+               .maxstack 8
+
+               ldnull 
+               ldftn !!1 class Driver::Foo<class Generic<object>, string> (!!0)
+               newobj instance void class Dele`2<class Generic<string>, string>::'.ctor'(object, native int)
+
+               pop 
+               ret 
+       }
+}
+
+  .class public auto ansi sealed Dele`2<T,R>
+       extends [mscorlib]System.MulticastDelegate
+  {
+    .method public hidebysig  specialname  rtspecialname 
+           instance default void '.ctor' (object 'object', native int 'method')  runtime managed 
+    {
+    }
+
+    .method public virtual  hidebysig  newslot 
+           instance default !R Invoke (!T t)  runtime managed 
+    {
+    }
+
+    .method public virtual  hidebysig  newslot 
+           instance default class [mscorlib]System.IAsyncResult BeginInvoke (!T t, class [mscorlib]System.AsyncCallback callback, object 'object')  runtime managed 
+    {
+    }
+
+    .method public virtual  hidebysig  newslot 
+           instance default !R EndInvoke (class [mscorlib]System.IAsyncResult result)  runtime managed 
+    {
+    }
+}
+
diff --git a/mono/tests/verifier/valid_convariant_delegate_2.il b/mono/tests/verifier/valid_convariant_delegate_2.il
new file mode 100644 (file)
index 0000000..516f19b
--- /dev/null
@@ -0,0 +1,71 @@
+.assembly extern mscorlib
+{
+  .ver 2:0:0:0
+  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+}
+.assembly 'valid_generic_delegate_1'
+{
+  .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() =  (
+               01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
+               63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01       ) // ceptionThrows.
+
+  .hash algorithm 0x00008004
+  .ver  0:0:0:0
+}
+.module valid_covariant_delegate.exe // GUID = {D9327351-CCFF-40F3-A80F-810E3C4283A7}
+
+.class interface public auto ansi beforefieldinit Generic<+T>
+{
+
+}
+
+.class public auto ansi beforefieldinit Driver extends [mscorlib]System.Object
+{
+       .method public static hidebysig default !!R Foo<T, R> (!!T arg)  cil managed 
+       {
+               .maxstack 8
+               .locals init (!!R l)
+               ldloca 0
+               initobj !!R
+               ldloc.0
+               ret 
+       }
+
+       .method public static hidebysig default void Main ()  cil managed 
+       {
+               .entrypoint
+               .maxstack 8
+
+               ldnull 
+               ldftn !!1 class Driver::Foo<object, class Generic<string>> (!!0)
+               newobj instance void class Dele`2<object, class Generic<object>>::'.ctor'(object, native int)
+
+               pop 
+               ret 
+       }
+}
+
+  .class public auto ansi sealed Dele`2<T,R>
+       extends [mscorlib]System.MulticastDelegate
+  {
+    .method public hidebysig  specialname  rtspecialname 
+           instance default void '.ctor' (object 'object', native int 'method')  runtime managed 
+    {
+    }
+
+    .method public virtual  hidebysig  newslot 
+           instance default !R Invoke (!T t)  runtime managed 
+    {
+    }
+
+    .method public virtual  hidebysig  newslot 
+           instance default class [mscorlib]System.IAsyncResult BeginInvoke (!T t, class [mscorlib]System.AsyncCallback callback, object 'object')  runtime managed 
+    {
+    }
+
+    .method public virtual  hidebysig  newslot 
+           instance default !R EndInvoke (class [mscorlib]System.IAsyncResult result)  runtime managed 
+    {
+    }
+}
+
diff --git a/mono/tests/verifier/valid_generic_delegate_1.cs b/mono/tests/verifier/valid_generic_delegate_1.cs
new file mode 100644 (file)
index 0000000..c1ae99e
--- /dev/null
@@ -0,0 +1,25 @@
+using System;
+
+public delegate T Dele<T,K> (K k);
+
+public class Foo <KEY> {
+
+       public VAL Method<VAL> (KEY k) {
+               Dele<VAL,KEY> t = new Dele<VAL,KEY> (Test<VAL>);
+                       
+               return t (k);
+       }
+
+       public static VAL Test<VAL> (KEY k) {
+               VAL v = default(VAL);
+               return v;
+       }
+}
+
+public class Driver {
+       public static void Main () {
+               new Foo<int>().Method<string>(99);
+       }
+
+       
+}
diff --git a/mono/tests/verifier/valid_generic_delegate_2.cs b/mono/tests/verifier/valid_generic_delegate_2.cs
new file mode 100644 (file)
index 0000000..9d1f85f
--- /dev/null
@@ -0,0 +1,30 @@
+using System;
+
+public delegate T Dele<T,K> (K k);
+
+public class Generic<T> {
+}
+
+public interface Foo9<T> {
+}
+public class Foo <KEY> {
+
+       public VAL Method<VAL> (Generic <KEY> k) {
+               Dele<VAL,Generic <KEY>> t = new Dele<VAL,Generic <KEY>> (Test<VAL>);
+                       
+               return t (k);
+       }
+
+       public static VAL Test<VAL> (Generic <KEY> k) {
+               VAL v = default(VAL);
+               return v;
+       }
+}
+
+public class Driver {
+       public static void Main () {
+               new Foo<int>().Method<string>(new Generic<int>());
+       }
+
+       
+}
diff --git a/mono/tests/verifier/valid_invariant_delegate.il b/mono/tests/verifier/valid_invariant_delegate.il
new file mode 100644 (file)
index 0000000..01a6e30
--- /dev/null
@@ -0,0 +1,70 @@
+.assembly extern mscorlib
+{
+  .ver 2:0:0:0
+  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+}
+.assembly 'valid_generic_delegate_1'
+{
+  .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() =  (
+               01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
+               63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01       ) // ceptionThrows.
+
+  .hash algorithm 0x00008004
+  .ver  0:0:0:0
+}
+.module valid_covariant_delegate.exe // GUID = {D9327351-CCFF-40F3-A80F-810E3C4283A7}
+.class public auto ansi beforefieldinit Generic<T> extends [mscorlib]System.Object
+{
+
+}
+
+.class public auto ansi beforefieldinit Driver extends [mscorlib]System.Object
+{
+       .method public static hidebysig default !!R Foo<T, R> (!!T arg)  cil managed 
+       {
+               .maxstack 8
+               .locals init (!!R l)
+               ldloca 0
+               initobj !!R
+               ldloc.0
+               ret 
+       }
+
+       .method public static hidebysig default void Main ()  cil managed 
+       {
+               .entrypoint
+               .maxstack 8
+
+               ldnull 
+               ldftn !!1 class Driver::Foo<class Generic<string>, string> (!!0)
+               newobj instance void class Dele`2<class Generic<string>, string>::'.ctor'(object, native int)
+
+               pop 
+               ret 
+       }
+}
+
+  .class public auto ansi sealed Dele`2<T,R>
+       extends [mscorlib]System.MulticastDelegate
+  {
+    .method public hidebysig  specialname  rtspecialname 
+           instance default void '.ctor' (object 'object', native int 'method')  runtime managed 
+    {
+    }
+
+    .method public virtual  hidebysig  newslot 
+           instance default !R Invoke (!T t)  runtime managed 
+    {
+    }
+
+    .method public virtual  hidebysig  newslot 
+           instance default class [mscorlib]System.IAsyncResult BeginInvoke (!T t, class [mscorlib]System.AsyncCallback callback, object 'object')  runtime managed 
+    {
+    }
+
+    .method public virtual  hidebysig  newslot 
+           instance default !R EndInvoke (class [mscorlib]System.IAsyncResult result)  runtime managed 
+    {
+    }
+}
+