2009-05-27 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / delegate.cs
index 24fe57e9120801c4c9315445e89339fd56e24766..8a5a7df610ffc52caf8d29537ffd62363c2ba336 100644 (file)
@@ -229,12 +229,9 @@ namespace Mono.CSharp {
                                return false;
                        }
 
-#if GMCS_SOURCE
-                       if (ret_type.IsGenericParameter && (ret_type.GenericParameterAttributes & GenericParameterAttributes.Contravariant) != 0) {
-                               Report.Error (-33, Location, "Contravariant type parameters can only be used in input positions");
-                               return false;
-                       }
-#endif
+                       var tp = TypeManager.LookupTypeParameter (ret_type);
+                       if (tp != null && tp.Variance == Variance.Contravariant)
+                               tp.ErrorInvalidVariance (this, Variance.Covariant);
 
                        //
                        // We don't have to check any others because they are all