[mcs] Caching of type argument types should not happen under error conditions. Fixes...
authorMarek Safar <marek.safar@gmail.com>
Wed, 30 Apr 2014 13:32:09 +0000 (15:32 +0200)
committerMarek Safar <marek.safar@gmail.com>
Wed, 30 Apr 2014 13:32:09 +0000 (15:32 +0200)
mcs/errors/cs0315-5.cs [new file with mode: 0644]
mcs/mcs/generic.cs

diff --git a/mcs/errors/cs0315-5.cs b/mcs/errors/cs0315-5.cs
new file mode 100644 (file)
index 0000000..5c857a6
--- /dev/null
@@ -0,0 +1,30 @@
+// CS0315: The type `int' cannot be used as type parameter `T' in the generic type or method `H<T>'. There is no boxing conversion from `int' to `I'
+// Line: 27
+
+using System;
+
+interface I
+{
+}
+
+class H<T> where T : I, new()
+{
+}
+
+public class A
+{
+       static void Test (Action a)
+       {
+       }
+
+       static void Foo<T>()
+       {
+       }
+
+       static void Main ()
+       {
+               Test (() => {
+                       Foo<H<int>> ();
+               });
+       }
+}
\ No newline at end of file
index e3bb7b0502b3d55047a30dc25b5928acd8d6b9a0..93eba5552944c163dd97552794eacdc2895e4e3a 100644 (file)
@@ -2153,6 +2153,8 @@ namespace Mono.CSharp {
 
                        atypes = new TypeSpec [count];
 
+                       var errors = ec.Module.Compiler.Report.Errors;
+
                        for (int i = 0; i < count; i++){
                                var te = args[i].ResolveAsType (ec);
                                if (te == null) {
@@ -2176,7 +2178,7 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       if (!ok)
+                       if (!ok || errors != ec.Module.Compiler.Report.Errors)
                                atypes = null;
 
                        return ok;
@@ -2396,6 +2398,8 @@ namespace Mono.CSharp {
                                return null;
 
                        TypeSpec[] atypes = args.Arguments;
+                       if (atypes == null)
+                               return null;
 
                        //
                        // Now bind the parameters