Author: marek
Date: 2006-03-19 11:33:09 -0500 (Sun, 19 Mar 2006)
New Revision: 58158

Modified:
   trunk/mcs/gmcs/class.cs
   trunk/mcs/gmcs/convert.cs
   trunk/mcs/gmcs/ecore.cs
   trunk/mcs/gmcs/expression.cs
   trunk/mcs/gmcs/generic.cs
   trunk/mcs/gmcs/typemanager.cs
Log:
manually synchronized with 56802

Modified: trunk/mcs/gmcs/class.cs
===================================================================
--- trunk/mcs/gmcs/class.cs     2006-03-19 16:32:53 UTC (rev 58157)
+++ trunk/mcs/gmcs/class.cs     2006-03-19 16:33:09 UTC (rev 58158)
@@ -5370,6 +5370,8 @@
                        ModFlags = Modifiers.Check (allowed_mod, mod, def_mod, 
Location);
                        IsExplicitImpl = (MemberName.Left != null);
                        GenericMethod = generic;
+                       if (GenericMethod != null)
+                               GenericMethod.ModFlags = ModFlags;
                }
 
                protected virtual bool CheckBase ()

Modified: trunk/mcs/gmcs/convert.cs
===================================================================
--- trunk/mcs/gmcs/convert.cs   2006-03-19 16:32:53 UTC (rev 58157)
+++ trunk/mcs/gmcs/convert.cs   2006-03-19 16:33:09 UTC (rev 58158)
@@ -86,6 +86,10 @@
                                return null;
                        }
 
+                       if (!gc.HasClassConstraint && 
!gc.HasConstructorConstraint && !gc.HasReferenceTypeConstraint &&
+                               !gc.HasValueTypeConstraint)
+                               return new ClassCast (expr, target_type);
+
                        // We're converting from a type parameter which is 
known to be a reference type.
                        Type base_type = TypeParam_EffectiveBaseType (gc);
 

Modified: trunk/mcs/gmcs/ecore.cs
===================================================================
--- trunk/mcs/gmcs/ecore.cs     2006-03-19 16:32:53 UTC (rev 58157)
+++ trunk/mcs/gmcs/ecore.cs     2006-03-19 16:33:09 UTC (rev 58158)
@@ -216,7 +216,7 @@
                // This is used if the expression should be resolved as a type 
or namespace name.
                // the default implementation fails.   
                //
-               public virtual FullNamedExpression ResolveAsTypeStep 
(EmitContext ec,  bool silent)
+               public virtual FullNamedExpression ResolveAsTypeStep 
(IResolveContext ec,  bool silent)
                {
                        return null;
                }
@@ -226,7 +226,7 @@
                // value will be returned if the expression is not a type
                // reference
                //
-               public virtual TypeExpr ResolveAsTypeTerminal (EmitContext ec, 
bool silent)
+               public virtual TypeExpr ResolveAsTypeTerminal (IResolveContext 
ec, bool silent)
                {
                        int errors = Report.Errors;
 
@@ -239,7 +239,7 @@
                        }
 
                        if (fne.eclass != ExprClass.Type) {
-                               if (!silent && (errors == Report.Errors))
+                               if (!silent && errors == Report.Errors)
                                        fne.Error_UnexpectedKind (null, "type", 
loc);
                                return null;
                        }
@@ -251,9 +251,15 @@
                                return null;
                        }
 
+                       // Constrains don't need to be checked for overrides
+                       GenericMethod gm = ec.DeclContainer as GenericMethod;
+                       if (gm != null && (gm.ModFlags & Modifiers.OVERRIDE) != 
0) {
+                               te.loc = loc;
+                               return te;
+                       }
+
                        ConstructedType ct = te as ConstructedType;
-                       if ((ct != null) && !ec.ResolvingTypeTree && 
!ec.ResolvingGenericMethod &&
-                           !ct.CheckConstraints (ec))
+                       if ((ct != null) && !ct.CheckConstraints (ec))
                                return null;
 
                        te.loc = loc;
@@ -1933,7 +1939,7 @@
                        return false;
                }
 
-               FullNamedExpression ResolveNested (EmitContext ec, Type t)
+               FullNamedExpression ResolveNested (IResolveContext ec, Type t)
                {
                        if (!t.IsGenericTypeDefinition)
                                return null;
@@ -1969,7 +1975,7 @@
                        return null;
                }
 
-               public override FullNamedExpression ResolveAsTypeStep 
(EmitContext ec, bool silent)
+               public override FullNamedExpression ResolveAsTypeStep 
(IResolveContext ec, bool silent)
                {
                        FullNamedExpression fne = 
ec.DeclContainer.LookupGeneric (Name, loc);
                        if (fne != null)
@@ -2227,7 +2233,7 @@
        ///   section 10.8.1 (Fully Qualified Names).
        /// </summary>
        public abstract class FullNamedExpression : Expression {
-               public override FullNamedExpression ResolveAsTypeStep 
(EmitContext ec, bool silent)
+               public override FullNamedExpression ResolveAsTypeStep 
(IResolveContext ec, bool silent)
                {
                        return this;
                }
@@ -2241,7 +2247,7 @@
        ///   Expression that evaluates to a type
        /// </summary>
        public abstract class TypeExpr : FullNamedExpression {
-               override public FullNamedExpression ResolveAsTypeStep 
(EmitContext ec, bool silent)
+               override public FullNamedExpression ResolveAsTypeStep 
(IResolveContext ec, bool silent)
                {
                        TypeExpr t = DoResolveAsTypeStep (ec);
                        if (t == null)
@@ -2299,9 +2305,9 @@
                        return true;
                }
 
-               protected abstract TypeExpr DoResolveAsTypeStep (EmitContext 
ec);
+               protected abstract TypeExpr DoResolveAsTypeStep 
(IResolveContext ec);
 
-               public Type ResolveType (EmitContext ec)
+               public Type ResolveType (IResolveContext ec)
                {
                        TypeExpr t = ResolveAsTypeTerminal (ec, false);
                        if (t == null)
@@ -2350,7 +2356,7 @@
                        loc = l;
                }
 
-               protected override TypeExpr DoResolveAsTypeStep (EmitContext ec)
+               protected override TypeExpr DoResolveAsTypeStep 
(IResolveContext ec)
                {
                        return this;
                }
@@ -2378,7 +2384,7 @@
                }
 
                static readonly char [] dot_array = { '.' };
-               protected override TypeExpr DoResolveAsTypeStep (EmitContext ec)
+               protected override TypeExpr DoResolveAsTypeStep 
(IResolveContext ec)
                {
                        if (type != null)
                                return this;
@@ -2461,7 +2467,7 @@
                        loc = l;
                }
 
-               protected override TypeExpr DoResolveAsTypeStep (EmitContext ec)
+               protected override TypeExpr DoResolveAsTypeStep 
(IResolveContext ec)
                {
                        Expression expr;
                        if (name.Left != null) {
@@ -2515,7 +2521,7 @@
                        get { return name; }
                }
 
-               protected override TypeExpr DoResolveAsTypeStep (EmitContext ec)
+               protected override TypeExpr DoResolveAsTypeStep 
(IResolveContext ec)
                {
                        texpr = alias.ResolveAsTypeTerminal (ec, false);
                        if (texpr == null)

Modified: trunk/mcs/gmcs/expression.cs
===================================================================
--- trunk/mcs/gmcs/expression.cs        2006-03-19 16:32:53 UTC (rev 58157)
+++ trunk/mcs/gmcs/expression.cs        2006-03-19 16:33:09 UTC (rev 58158)
@@ -7231,7 +7231,7 @@
                        loc = l;
                }
 
-               public override FullNamedExpression ResolveAsTypeStep 
(EmitContext ec, bool silent)
+               public override FullNamedExpression ResolveAsTypeStep 
(IResolveContext ec, bool silent)
                {
                        if (alias == "global")
                                return new MemberAccess (RootNamespace.Global, 
identifier, loc).ResolveAsTypeStep (ec, silent);
@@ -7455,12 +7455,12 @@
                        return DoResolve (ec, right_side);
                }
 
-               public override FullNamedExpression ResolveAsTypeStep 
(EmitContext ec, bool silent)
+               public override FullNamedExpression ResolveAsTypeStep 
(IResolveContext ec, bool silent)
                {
                        return ResolveNamespaceOrType (ec, silent);
                }
 
-               public FullNamedExpression ResolveNamespaceOrType (EmitContext 
ec, bool silent)
+               public FullNamedExpression ResolveNamespaceOrType 
(IResolveContext ec, bool silent)
                {
                        FullNamedExpression new_expr = expr.ResolveAsTypeStep 
(ec, silent);
 
@@ -7493,11 +7493,11 @@
                        }
 
                        Expression member_lookup = MemberLookup (
-                               ec.ContainerType, expr_type, expr_type, 
lookup_id,
+                               ec.DeclContainer.TypeBuilder, expr_type, 
expr_type, lookup_id,
                                MemberTypes.NestedType, BindingFlags.Public | 
BindingFlags.NonPublic, loc);
                        if (member_lookup == null) {
                                int errors = Report.Errors;
-                               MemberLookupFailed (ec.ContainerType, 
expr_type, expr_type, lookup_id, null, false, loc);
+                               MemberLookupFailed 
(ec.DeclContainer.TypeBuilder, expr_type, expr_type, lookup_id, null, false, 
loc);
 
                                if (!silent && errors == Report.Errors) {
                                        Report.Error (426, loc, "The nested 
type `{0}' does not exist in the type `{1}'",
@@ -8786,7 +8786,7 @@
                        return this;
                }
 
-               protected override TypeExpr DoResolveAsTypeStep (EmitContext ec)
+               protected override TypeExpr DoResolveAsTypeStep 
(IResolveContext ec)
                {
                        TypeExpr lexpr = left.ResolveAsTypeTerminal (ec, false);
                        if (lexpr == null)

Modified: trunk/mcs/gmcs/generic.cs
===================================================================
--- trunk/mcs/gmcs/generic.cs   2006-03-19 16:32:53 UTC (rev 58157)
+++ trunk/mcs/gmcs/generic.cs   2006-03-19 16:33:09 UTC (rev 58158)
@@ -1039,7 +1039,7 @@
                        this.loc = loc;
                }
 
-               protected override TypeExpr DoResolveAsTypeStep (EmitContext ec)
+               protected override TypeExpr DoResolveAsTypeStep 
(IResolveContext ec)
                {
                        type = type_parameter.Type;
 
@@ -1180,7 +1180,7 @@
                /// <summary>
                ///   Resolve the type arguments.
                /// </summary>
-               public bool Resolve (EmitContext ec)
+               public bool Resolve (IResolveContext ec)
                {
                        int count = args.Count;
                        bool ok = true;
@@ -1306,7 +1306,7 @@
                        return TypeManager.CSharpName (gt);
                }
 
-               protected override TypeExpr DoResolveAsTypeStep (EmitContext ec)
+               protected override TypeExpr DoResolveAsTypeStep 
(IResolveContext ec)
                {
                        if (!ResolveConstructedType (ec))
                                return null;
@@ -1318,7 +1318,7 @@
                ///   Check the constraints; we're called from 
ResolveAsTypeTerminal()
                ///   after fully resolving the constructed type.
                /// </summary>
-               public bool CheckConstraints (EmitContext ec)
+               public bool CheckConstraints (IResolveContext ec)
                {
                        return ConstraintChecker.CheckConstraints (ec, gt, 
gen_params, atypes, loc);
                }
@@ -1326,7 +1326,7 @@
                /// <summary>
                ///   Resolve the constructed type, but don't check the 
constraints.
                /// </summary>
-               public bool ResolveConstructedType (EmitContext ec)
+               public bool ResolveConstructedType (IResolveContext ec)
                {
                        if (type != null)
                                return true;
@@ -1355,7 +1355,7 @@
                        return DoResolveType (ec);
                }
 
-               bool DoResolveType (EmitContext ec)
+               bool DoResolveType (IResolveContext ec)
                {
                        //
                        // Resolve the arguments.
@@ -1461,7 +1461,7 @@
                ///   Check the constraints; we're called from 
ResolveAsTypeTerminal()
                ///   after fully resolving the constructed type.
                /// </summary>
-               public bool CheckConstraints (EmitContext ec)
+               public bool CheckConstraints (IResolveContext ec)
                {
                        for (int i = 0; i < gen_params.Length; i++) {
                                if (!CheckConstraints (ec, i))
@@ -1471,7 +1471,7 @@
                        return true;
                }
 
-               protected bool CheckConstraints (EmitContext ec, int index)
+               protected bool CheckConstraints (IResolveContext ec, int index)
                {
                        Type atype = atypes [index];
                        Type ptype = gen_params [index];
@@ -1495,6 +1495,10 @@
                                        is_class = is_struct = false;
                                }
                        } else {
+#if MS_COMPATIBLE
+                               is_class = false;
+                               if (!atype.IsGenericType)
+#endif
                                is_class = atype.IsClass || atype.IsInterface;
                                is_struct = atype.IsValueType && 
!TypeManager.IsNullableType (atype);
                        }
@@ -1533,9 +1537,11 @@
                        //
                        // Now, check the interface constraints.
                        //
-                       foreach (Type it in gc.InterfaceConstraints) {
-                               if (!CheckConstraint (ec, ptype, aexpr, it))
-                                       return false;
+                       if (gc.InterfaceConstraints != null) {
+                               foreach (Type it in gc.InterfaceConstraints) {
+                                       if (!CheckConstraint (ec, ptype, aexpr, 
it))
+                                               return false;
+                               }
                        }
 
                        //
@@ -1548,7 +1554,7 @@
                        if (TypeManager.IsBuiltinType (atype) || 
atype.IsValueType)
                                return true;
 
-                       if (HasDefaultConstructor (ec.ContainerType, atype))
+                       if (HasDefaultConstructor 
(ec.DeclContainer.TypeBuilder, atype))
                                return true;
 
                        Report_SymbolRelatedToPreviousError ();
@@ -1563,7 +1569,7 @@
                        return false;
                }
 
-               protected bool CheckConstraint (EmitContext ec, Type ptype, 
Expression expr,
+               protected bool CheckConstraint (IResolveContext ec, Type ptype, 
Expression expr,
                                                Type ctype)
                {
                        if (TypeManager.HasGenericArguments (ctype)) {
@@ -1665,7 +1671,7 @@
                        return checker.CheckConstraints (ec);
                }
 
-               public static bool CheckConstraints (EmitContext ec, Type gt, 
Type[] gen_params,
+               public static bool CheckConstraints (IResolveContext ec, Type 
gt, Type[] gen_params,
                                                     Type[] atypes, Location 
loc)
                {
                        TypeConstraintChecker checker = new 
TypeConstraintChecker (
@@ -1900,7 +1906,7 @@
                        get { return underlying.ToString () + "?"; }
                }
 
-               protected override TypeExpr DoResolveAsTypeStep (EmitContext ec)
+               protected override TypeExpr DoResolveAsTypeStep 
(IResolveContext ec)
                {
                        TypeArguments args = new TypeArguments (loc);
                        args.Add (underlying);

Modified: trunk/mcs/gmcs/typemanager.cs
===================================================================
--- trunk/mcs/gmcs/typemanager.cs       2006-03-19 16:32:53 UTC (rev 58157)
+++ trunk/mcs/gmcs/typemanager.cs       2006-03-19 16:33:09 UTC (rev 58158)
@@ -1272,6 +1272,11 @@
        public static MemberList FindMembers (Type t, MemberTypes mt, 
BindingFlags bf,
                                              MemberFilter filter, object 
criteria)
        {
+#if MS_COMPATIBLE
+               if (t.IsGenericType)
+                       t = t.GetGenericTypeDefinition ();
+#endif
+
                DeclSpace decl = (DeclSpace) builder_to_declspace [t];
 
                //
@@ -1594,6 +1599,11 @@
                        return tparam.IsSubclassOf (base_type);
                }
 
+#if MS_COMPATIBLE
+               if (type.IsGenericType)
+                       type = type.GetGenericTypeDefinition ();
+#endif
+
                if (type.IsSubclassOf (base_type))
                        return true;
 
@@ -2089,10 +2099,14 @@
                                base_ifaces = GetInterfaces (t.BaseType);
                        Type[] type_ifaces;
                        if (t.IsGenericType)
+#if MS_COMPATIBLE
+                               type_ifaces = 
t.GetGenericTypeDefinition().GetInterfaces ();
+#else
                                type_ifaces = t.GetInterfaces ();
+#endif
                        else
                                type_ifaces = (Type []) builder_to_ifaces [t];
-                       if (type_ifaces == null)
+                       if (type_ifaces == null || type_ifaces.Length == 0)
                                type_ifaces = Type.EmptyTypes;
 
                        int base_count = base_ifaces.Length;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to