New test.
[mono.git] / mcs / gmcs / generic.cs
index cdb31375ec952580bba932124646462094d78afd..b75b603d295d3d632b991773039f878eec285206 100644 (file)
@@ -156,6 +156,11 @@ namespace Mono.CSharp {
                        }
                }
 
+               public Constraints Clone ()
+               {
+                       return new Constraints (name, constraints, loc);
+               }
+
                GenericParameterAttributes attrs;
                TypeExpr class_constraint;
                ArrayList iface_constraints;
@@ -758,7 +763,7 @@ namespace Mono.CSharp {
                                                TypeManager.CSharpName (mparam), TypeManager.CSharpSignature (mb));
                                        return false;
                                }
-                       } else if (DeclSpace is Iterator) {
+                       } else if (DeclSpace is CompilerGeneratedClass) {
                                TypeParameter[] tparams = DeclSpace.TypeParameters;
                                Type[] types = new Type [tparams.Length];
                                for (int i = 0; i < tparams.Length; i++)
@@ -1244,11 +1249,13 @@ namespace Mono.CSharp {
                                if (te is TypeParameterExpr)
                                        has_type_args = true;
 
+#if !MS_COMPATIBLE
                                if (te.Type.IsSealed && te.Type.IsAbstract) {
                                        Report.Error (718, Location, "`{0}': static classes cannot be used as generic arguments",
                                                te.GetSignatureForError ());
                                        return false;
                                }
+#endif
                                if (te.Type.IsPointer) {
                                        Report.Error (306, Location, "The type `{0}' may not be used " +
                                                          "as a type argument", TypeManager.CSharpName (te.Type));
@@ -1448,6 +1455,11 @@ namespace Mono.CSharp {
 
                public override bool AsAccessible (DeclSpace ds, int flags)
                {
+                       foreach (Type t in atypes) {
+                               if (!ds.AsAccessible (t, flags))
+                                       return false;
+                       }
+
                        return ds.AsAccessible (gt, flags);
                }
 
@@ -1544,8 +1556,8 @@ namespace Mono.CSharp {
                                if (agc != null) {
                                        if (agc is Constraints)
                                                ((Constraints) agc).Resolve (ec);
-                                       is_class = agc.HasReferenceTypeConstraint;
-                                       is_struct = agc.HasValueTypeConstraint;
+                                       is_class = agc.IsReferenceType;
+                                       is_struct = agc.IsValueType;
                                } else {
                                        is_class = is_struct = false;
                                }
@@ -2458,7 +2470,7 @@ namespace Mono.CSharp {
 
                                Argument a = (Argument) arguments [i];
                                if ((a.Expr is NullLiteral) || (a.Expr is MethodGroupExpr) ||
-                                   (a.Expr is AnonymousMethod))
+                                   (a.Expr is AnonymousMethodExpression))
                                        continue;
 
                                arg_types [i] = a.Type;
@@ -3242,14 +3254,13 @@ namespace Mono.CSharp {
                                        return this;
                                }
 
-                               if (unwrap != null) {
-                                       expr = Convert.ImplicitConversion (ec, unwrap, rtype, loc);
-                                       if (expr != null) {
-                                               left = expr;
-                                               expr = right;
-                                               type = expr.Type;
-                                               return this;
-                                       }
+                               Expression left_null = unwrap != null ? unwrap : left;
+                               expr = Convert.ImplicitConversion (ec, left_null, rtype, loc);
+                               if (expr != null) {
+                                       left = expr;
+                                       expr = right;
+                                       type = rtype;
+                                       return this;
                                }
 
                                Binary.Error_OperatorCannotBeApplied (loc, "??", ltype, rtype);