2003-07-22 Ravi Pratap <ravi@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Thu, 24 Jul 2003 09:55:13 +0000 (09:55 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Thu, 24 Jul 2003 09:55:13 +0000 (09:55 -0000)
* expression.cs (Invocation.OverloadResolve): Follow the spec more
closely: we eliminate methods in base types when we have an
applicable method in a top-level type.

        Please see section 14.5.5.1 for an exact description of what goes
on.

This fixes bug #45127 and a host of other related to corlib compilation.

        * ecore.cs (MethodGroupExpr.DeclaringType): The element in the
array is the method corresponding to the top-level type (this is
because of the changes made to icall.c) so we change this
accordingly.

(MethodGroupExpr.Name): This too.

* typemanager.cs (GetElementType): New method which does the right
thing when compiling corlib.

* everywhere: Make use of the above in the relevant places.

svn path=/trunk/mcs/; revision=16599

mcs/mcs/ChangeLog
mcs/mcs/class.cs
mcs/mcs/convert.cs
mcs/mcs/decl.cs
mcs/mcs/ecore.cs
mcs/mcs/expression.cs
mcs/mcs/parameter.cs
mcs/mcs/rootcontext.cs
mcs/mcs/statement.cs
mcs/mcs/support.cs
mcs/mcs/typemanager.cs

index ed9262a950fca468ba21f774a6efc172a5a80059..ec6d491e6dbee1ee5f1061a2193b33d3496f5f49 100755 (executable)
@@ -1,3 +1,26 @@
+2003-07-22  Ravi Pratap  <ravi@ximian.com>
+
+       * expression.cs (Invocation.OverloadResolve): Follow the spec more
+       closely: we eliminate methods in base types when we have an
+       applicable method in a top-level type.
+
+        Please see section 14.5.5.1 for an exact description of what goes
+       on. 
+
+       This fixes bug #45127 and a host of other related to corlib compilation.
+
+        * ecore.cs (MethodGroupExpr.DeclaringType): The element in the
+       array is the method corresponding to the top-level type (this is
+       because of the changes made to icall.c) so we change this
+       accordingly.
+
+       (MethodGroupExpr.Name): This too.
+
+       * typemanager.cs (GetElementType): New method which does the right
+       thing when compiling corlib. 
+
+       * everywhere: Make use of the above in the relevant places.
+
 2003-07-22  Martin Baulig  <martin@ximian.com>
 
        * cs-parser.jay (invocation_expression): Moved
index 19ee88d1b099b03853ad3a3a7f7eabf468630b97..11e5b3010b204b56e954cefb3e9f5e57a143aa91 100755 (executable)
@@ -1806,7 +1806,7 @@ namespace Mono.CSharp {
                public bool AsAccessible (Type parent, int flags)
                {
                        while (parent.IsArray || parent.IsPointer || parent.IsByRef)
-                               parent = parent.GetElementType ();
+                               parent = TypeManager.GetElementType (parent);
 
                        AccessLevel level = GetAccessLevel (flags);
                        AccessLevel level2 = GetAccessLevel (parent, flags);
@@ -2400,7 +2400,7 @@ namespace Mono.CSharp {
                         Type t = pinfo.ParameterType(0);
                         if (t.IsArray &&
                             (t.GetArrayRank() == 1) &&
-                            (t.GetElementType() == TypeManager.string_type) &&
+                            (TypeManager.GetElementType(t) == TypeManager.string_type) &&
                             (pinfo.ParameterModifier(0) == Parameter.Modifier.NONE))
                                 return true;
                         else
@@ -3480,7 +3480,7 @@ namespace Mono.CSharp {
                                if (partype.IsPointer){
                                        if (!UnsafeOK (container))
                                                error = true;
-                                       if (!TypeManager.VerifyUnManaged (partype.GetElementType (), Location))
+                                       if (!TypeManager.VerifyUnManaged (TypeManager.GetElementType (partype), Location))
                                                error = true;
                                }
 
index 6625ccf511b794d091b12dc3c6d037e16eaa0375..ad577caa190f13a314dcbe4d41d8ec67cea14cf8 100644 (file)
@@ -105,13 +105,13 @@ namespace Mono.CSharp {
                                if (expr_type.IsArray && target_type.IsArray) {
                                        if (expr_type.GetArrayRank () == target_type.GetArrayRank ()) {
 
-                                               Type expr_element_type = expr_type.GetElementType ();
+                                               Type expr_element_type = TypeManager.GetElementType (expr_type);
 
                                                if (MyEmptyExpr == null)
                                                        MyEmptyExpr = new EmptyExpression ();
                                                
                                                MyEmptyExpr.SetType (expr_element_type);
-                                               Type target_element_type = target_type.GetElementType ();
+                                               Type target_element_type = TypeManager.GetElementType (target_type);
 
                                                if (!expr_element_type.IsValueType && !target_element_type.IsValueType)
                                                        if (ImplicitStandardConversionExists (MyEmptyExpr,
@@ -187,7 +187,7 @@ namespace Mono.CSharp {
                                                        MyEmptyExpr = new EmptyExpression ();
                                                
                                                MyEmptyExpr.SetType (expr_element_type);
-                                               Type target_element_type = target_type.GetElementType ();
+                                               Type target_element_type = TypeManager.GetElementType (target_type);
                                                
                                                if (!expr_element_type.IsValueType && !target_element_type.IsValueType)
                                                        if (ImplicitStandardConversionExists (MyEmptyExpr,
@@ -397,7 +397,7 @@ namespace Mono.CSharp {
                /// </summary>
                public static bool ImplicitConversionExists (EmitContext ec, Expression expr, Type target_type)
                {
-                       if (ImplicitStandardConversionExists (expr, target_type) == true)
+                       if (ImplicitStandardConversionExists (expr, target_type))
                                return true;
 
                        Expression dummy = ImplicitUserConversion (ec, expr, target_type, Location.Null);
@@ -425,10 +425,14 @@ namespace Mono.CSharp {
 
                        if (expr_type == TypeManager.void_type)
                                return false;
-                       
+
+                        //Console.WriteLine ("Expr is {0}", expr);
+                        //Console.WriteLine ("{0} -> {1} ?", expr_type, target_type);
                        if (expr_type == target_type)
                                return true;
 
+                        //Console.WriteLine ("No !!");
+
                        // First numeric conversions 
 
                        if (expr_type == TypeManager.sbyte_type){
@@ -1055,7 +1059,7 @@ namespace Mono.CSharp {
                                        // t1 == t2, we have to compare their element types.
                                        //
                                        if (target_type.IsPointer){
-                                               if (target_type.GetElementType() == expr_type.GetElementType())
+                                               if (TypeManager.GetElementType(target_type) == TypeManager.GetElementType(expr_type))
                                                        return expr;
                                        }
                                }
@@ -1435,8 +1439,8 @@ namespace Mono.CSharp {
                        if (source_type.IsArray && target_type.IsArray) {
                                if (source_type.GetArrayRank () == target_type.GetArrayRank ()) {
                                        
-                                       Type source_element_type = source_type.GetElementType ();
-                                       Type target_element_type = target_type.GetElementType ();
+                                       Type source_element_type = TypeManager.GetElementType (source_type);
+                                       Type target_element_type = TypeManager.GetElementType (target_type);
                                        
                                        if (!source_element_type.IsValueType && !target_element_type.IsValueType)
                                                if (ExplicitReferenceConversionExists (source_element_type,
@@ -1534,8 +1538,8 @@ namespace Mono.CSharp {
                        if (source_type.IsArray && target_type.IsArray) {
                                if (source_type.GetArrayRank () == target_type.GetArrayRank ()) {
                                        
-                                       Type source_element_type = source_type.GetElementType ();
-                                       Type target_element_type = target_type.GetElementType ();
+                                       Type source_element_type = TypeManager.GetElementType (source_type);
+                                       Type target_element_type = TypeManager.GetElementType (target_type);
                                        
                                        if (!source_element_type.IsValueType && !target_element_type.IsValueType)
                                                if (ExplicitReferenceConversionExists (source_element_type,
index 4c7e0428fd4b9bd17a0c901db525200b230964ba..02316464f346d2ecef22dac626e3c4deb7ef4fd8 100755 (executable)
@@ -524,7 +524,7 @@ namespace Mono.CSharp {
                        // NonPublic visibility for pointers
                        //
                        if (check_type.IsArray || check_type.IsPointer)
-                               return CheckAccessLevel (check_type.GetElementType ());
+                               return CheckAccessLevel (TypeManager.GetElementType (check_type));
 
                        switch (check_attr){
                        case TypeAttributes.Public:
@@ -1006,9 +1006,9 @@ namespace Mono.CSharp {
 
                        // If we have a parent class (we have a parent class unless we're
                        // TypeManager.object_type), we deep-copy its MemberCache here.
-                       if (Container.Parent != null)
+                       if (Container.Parent != null) {
                                member_hash = SetupCache (Container.Parent.MemberCache);
-                       else if (Container.IsInterface)
+                       else if (Container.IsInterface)
                                member_hash = SetupCacheForInterface ();
                        else
                                member_hash = new Hashtable ();
@@ -1037,8 +1037,8 @@ namespace Mono.CSharp {
                        IDictionaryEnumerator it = parent.member_hash.GetEnumerator ();
                        while (it.MoveNext ()) {
                                hash [it.Key] = ((ArrayList) it.Value).Clone ();
-                       }
-
+                        }
+                                
                        return hash;
                }
 
index c10835bdae4c738392c628bae53838cfc0689c3d..60f583b959fb9834cb649f5db4afd289292da0e6 100755 (executable)
@@ -2267,6 +2267,7 @@ namespace Mono.CSharp {
                                }
                                throw;
                        }
+
                        loc = l;
                        eclass = ExprClass.MethodGroup;
                        type = TypeManager.object_type;
@@ -2274,7 +2275,11 @@ namespace Mono.CSharp {
 
                public Type DeclaringType {
                        get {
-                               return Methods [0].DeclaringType;
+                                //
+                                // We assume that the top-level type is in the end
+                                //
+                               return Methods [Methods.Length - 1].DeclaringType;
+                                //return Methods [0].DeclaringType;
                        }
                }
                
@@ -2303,7 +2308,8 @@ namespace Mono.CSharp {
 
                public string Name {
                        get {
-                               return Methods [0].Name;
+                               //return Methods [0].Name;
+                                return Methods [Methods.Length - 1].Name;
                        }
                }
 
@@ -2343,8 +2349,8 @@ namespace Mono.CSharp {
 
                public void ReportUsageError ()
                {
-                       Report.Error (654, loc, "Method `" + Methods [0].DeclaringType + "." +
-                                     Methods [0].Name + "()' is referenced without parentheses");
+                       Report.Error (654, loc, "Method `" + DeclaringType + "." +
+                                     Name + "()' is referenced without parentheses");
                }
 
                override public void Emit (EmitContext ec)
index 966484c26a6040f25490e53c4188eca6d73b7f21..50f367fe34b7a6b9b5c2f4938c09c106a6cf8b63 100755 (executable)
@@ -607,7 +607,7 @@ namespace Mono.CSharp {
                public Indirection (Expression expr, Location l)
                {
                        this.expr = expr;
-                       this.type = TypeManager.TypeToCoreType (expr.Type.GetElementType ());
+                       this.type = TypeManager.GetElementType (expr.Type);
                        eclass = ExprClass.Variable;
                        loc = l;
                }
@@ -848,7 +848,7 @@ namespace Mono.CSharp {
 
                static int PtrTypeSize (Type t)
                {
-                       return GetTypeSize (t.GetElementType ());
+                       return GetTypeSize (TypeManager.GetElementType (t));
                }
 
                //
@@ -3256,7 +3256,7 @@ namespace Mono.CSharp {
                {
                        Type op_type = left.Type;
                        ILGenerator ig = ec.ig;
-                       int size = GetTypeSize (op_type.GetElementType ());
+                       int size = GetTypeSize (TypeManager.GetElementType (op_type));
                        Type rtype = right.Type;
                        
                        if (rtype.IsPointer){
@@ -4169,7 +4169,7 @@ namespace Mono.CSharp {
 
                                        if (candidate_pd.ParameterModifier (j) == Parameter.Modifier.PARAMS)
                                                if (expanded_form)
-                                                       t = t.GetElementType ();
+                                                       t = TypeManager.GetElementType (t);
 
                                        x = BetterConversion (ec, a, t, null, loc);
                                        
@@ -4197,11 +4197,11 @@ namespace Mono.CSharp {
 
                                if (candidate_pd.ParameterModifier (j) == Parameter.Modifier.PARAMS)
                                        if (expanded_form)
-                                               ct = ct.GetElementType ();
+                                               ct = TypeManager.GetElementType (ct);
 
                                if (best_pd.ParameterModifier (j) == Parameter.Modifier.PARAMS)
                                        if (expanded_form)
-                                               bt = bt.GetElementType ();
+                                               bt = TypeManager.GetElementType (bt);
                                
                                x = BetterConversion (ec, a, ct, bt, loc);
                                y = BetterConversion (ec, a, bt, ct, loc);
@@ -4360,7 +4360,7 @@ namespace Mono.CSharp {
                                
                        }
 
-                       Type element_type = pd.ParameterType (pd_count - 1).GetElementType ();
+                       Type element_type = TypeManager.GetElementType (pd.ParameterType (pd_count - 1));
 
                        for (int i = pd_count - 1; i < arg_count; i++) {
                                Argument a = (Argument) arguments [i];
@@ -4392,7 +4392,7 @@ namespace Mono.CSharp {
 
                        if (arg_count != pd.Count)
                                return false;
-                       
+
                        for (int i = arg_count; i > 0; ) {
                                i--;
 
@@ -4406,9 +4406,11 @@ namespace Mono.CSharp {
 
                                if (a_mod == p_mod ||
                                    (a_mod == Parameter.Modifier.NONE && p_mod == Parameter.Modifier.PARAMS)) {
-                                       if (a_mod == Parameter.Modifier.NONE)
-                                               if (!Convert.ImplicitConversionExists (ec, a.Expr, pd.ParameterType (i)))
+                                       if (a_mod == Parameter.Modifier.NONE) {
+                                                 if (!Convert.ImplicitConversionExists (ec,
+                                                                                       a.Expr, pd.ParameterType (i)))
                                                        return false;
+                                        }
                                        
                                        if ((a_mod & Parameter.Modifier.ISBYREF) != 0) {
                                                Type pt = pd.ParameterType (i);
@@ -4448,44 +4450,70 @@ namespace Mono.CSharp {
                                                          ArrayList Arguments, Location loc)
                {
                        MethodBase method = null;
-                       Type current_type = null;
+                       Type applicable_type = null;
                        int argument_count;
                        ArrayList candidates = new ArrayList ();
-                       
 
-                       foreach (MethodBase candidate in me.Methods){
-                               int x;
+                        //
+                        // First we construct the set of applicable methods
+                        //
+
+                        //
+                        // We start at the top of the type hierarchy and
+                        // go down to find applicable methods
+                        //
+                        applicable_type = me.DeclaringType;
+
+                        bool found_applicable = false;
+                       foreach (MethodBase candidate in me.Methods) {
+                                Type decl_type = candidate.DeclaringType;
+
+                                //
+                                // If we have already found an applicable method
+                                // we eliminate all base types (Section 14.5.5.1)
+                                //
+                                if (decl_type != applicable_type &&
+                                    (applicable_type.IsSubclassOf (decl_type) ||
+                                     TypeManager.ImplementsInterface (applicable_type, decl_type)) &&
+                                    found_applicable)
+                                                continue;
 
-                               // If we're going one level higher in the class hierarchy, abort if
-                               // we already found an applicable method.
-                               if (candidate.DeclaringType != current_type) {
-                                       current_type = candidate.DeclaringType;
-                                       if (method != null)
-                                               break;
-                               }
 
                                // Check if candidate is applicable (section 14.4.2.1)
                                if (!IsApplicable (ec, Arguments, candidate))
                                        continue;
 
+                                
                                candidates.Add (candidate);
-                               x = BetterFunction (ec, Arguments, candidate, method, false, loc);
-                               
-                               if (x == 0)
-                                       continue;
+                                applicable_type = candidate.DeclaringType;
+                                found_applicable = true;
 
-                               method = candidate;
                        }
 
+
+                        //
+                        // Now we actually find the best method
+                        //
+                        foreach (MethodBase candidate in candidates) {
+                                int x = BetterFunction (ec, Arguments, candidate, method, false, loc);
+                                
+                                if (x == 0)
+                                        continue;
+                                
+                                method = candidate;
+                        }
+
+
                        if (Arguments == null)
                                argument_count = 0;
                        else
                                argument_count = Arguments.Count;
                        
                        //
-                       // Now we see if we can find params functions, applicable in their expanded form
-                       // since if they were applicable in their normal form, they would have been selected
-                       // above anyways
+                       // Now we see if we can find params functions,
+                       // applicable in their expanded form since if
+                       // they were applicable in their normal form,
+                       // they would have been selected above anyways
                        //
                        bool chose_params_expanded = false;
                        
@@ -4544,11 +4572,15 @@ namespace Mono.CSharp {
                                        continue;
 
                                //
-                               // If a normal method is applicable in the sense that it has the same
-                               // number of arguments, then the expanded params method is never applicable
-                               // so we debar the params method.
+                               // If a normal method is applicable in
+                               // the sense that it has the same
+                               // number of arguments, then the
+                               // expanded params method is never
+                               // applicable so we debar the params
+                               // method.
                                //
-                               if (IsParamsMethodApplicable (ec, Arguments, candidate) &&
+
+                                if (IsParamsMethodApplicable (ec, Arguments, candidate) &&
                                    IsApplicable (ec, Arguments, method))
                                        continue;
                                        
@@ -4564,8 +4596,10 @@ namespace Mono.CSharp {
                        }
 
                        //
-                       // And now check if the arguments are all compatible, perform conversions
-                       // if necessary etc. and return if everything is all right
+                       // And now check if the arguments are all
+                       // compatible, perform conversions if
+                       // necessary etc. and return if everything is
+                       // all right
                        //
 
                        if (!VerifyArgumentsCompat (ec, Arguments, argument_count, method,
@@ -4627,7 +4661,7 @@ namespace Mono.CSharp {
                                        }
 
                                        if (chose_params_expanded)
-                                               parameter_type = TypeManager.TypeToCoreType (parameter_type.GetElementType ());
+                                               parameter_type = TypeManager.GetElementType (parameter_type);
                                } else {
                                        //
                                        // Check modifiers
@@ -4650,6 +4684,11 @@ namespace Mono.CSharp {
                                        conv = Convert.ImplicitConversion (ec, a_expr, parameter_type, loc);
 
                                        if (conv == null) {
+                                                Console.WriteLine ("GAA: {0} {1} {2}",
+                                                                   pd.ParameterType (j),
+                                                                   pd.ParameterType (j).Assembly == CodeGen.AssemblyBuilder,
+                                                                   method.DeclaringType.Assembly == CodeGen.AssemblyBuilder);
+
                                                if (!Location.IsNull (loc)) 
                                                        Error_InvalidArguments (
                                                                loc, j, method, delegate_type,
@@ -4838,7 +4877,7 @@ namespace Mono.CSharp {
                                        ILGenerator ig = ec.ig;
 
                                        IntConstant.EmitInt (ig, 0);
-                                       ig.Emit (OpCodes.Newarr, pd.ParameterType (0).GetElementType ());
+                                       ig.Emit (OpCodes.Newarr, TypeManager.GetElementType (pd.ParameterType (0)));
                                }
 
                                return;
@@ -4871,7 +4910,7 @@ namespace Mono.CSharp {
                                ILGenerator ig = ec.ig;
 
                                IntConstant.EmitInt (ig, 0);
-                               ig.Emit (OpCodes.Newarr, pd.ParameterType (top).GetElementType ());
+                               ig.Emit (OpCodes.Newarr, TypeManager.GetElementType (pd.ParameterType (top)));
                        }
                }
 
@@ -5686,7 +5725,7 @@ namespace Mono.CSharp {
 
                        underlying_type = type;
                        if (underlying_type.IsArray)
-                               underlying_type = TypeManager.TypeToCoreType (underlying_type.GetElementType ());
+                               underlying_type = TypeManager.GetElementType (underlying_type);
                        dimensions = type.GetArrayRank ();
 
                        return true;
@@ -5722,7 +5761,7 @@ namespace Mono.CSharp {
                                }
                        }
                        
-                       array_element_type = TypeManager.TypeToCoreType (type.GetElementType ());
+                       array_element_type = TypeManager.GetElementType (type);
 
                        if (arg_count == 1) {
                                is_one_dimensional = true;
@@ -7025,8 +7064,9 @@ namespace Mono.CSharp {
                                          ea.Arguments.Count);
                                return null;
                        }
-                       type = TypeManager.TypeToCoreType (t.GetElementType ());
-                       if (type.IsPointer && !ec.InUnsafe){
+
+                        type = TypeManager.GetElementType (t);
+                        if (type.IsPointer && !ec.InUnsafe){
                                UnsafeError (ea.Location);
                                return null;
                        }
@@ -7865,7 +7905,7 @@ namespace Mono.CSharp {
                
                public ArrayPtr (Expression array, Location l)
                {
-                       Type array_type = array.Type.GetElementType ();
+                       Type array_type = TypeManager.GetElementType (array.Type);
 
                        this.array = array;
 
@@ -7880,7 +7920,7 @@ namespace Mono.CSharp {
                        
                        array.Emit (ec);
                        IntLiteral.EmitInt (ig, 0);
-                       ig.Emit (OpCodes.Ldelema, array.Type.GetElementType ());
+                       ig.Emit (OpCodes.Ldelema, TypeManager.GetElementType (array.Type));
                }
 
                public override Expression DoResolve (EmitContext ec)
index c2567e4f5a19542c14efdb9fd401992d828d5297..2eaeb020919c40ccfb5492aa6c82feab37ef92e4 100755 (executable)
@@ -56,7 +56,7 @@ namespace Mono.CSharp {
                                Report.Error (1536, l, "`void' parameter is not permitted");
                                return false;
                        }
-                       
+
                        return parameter_type != null;
                }
 
index 297ebd9612c941483eb79abdc6333091de0e33c7..74e39fd3d5f3a081a0b598e8a3a1536e6abede22 100755 (executable)
@@ -866,7 +866,10 @@ namespace Mono.CSharp {
                        
                        if (impl_details_class == null){
                                impl_details_class = CodeGen.ModuleBuilder.DefineType (
-                                       "<PrivateImplementationDetails>", TypeAttributes.NotPublic, TypeManager.object_type);
+                                       "<PrivateImplementationDetails>",
+                                        TypeAttributes.NotPublic,
+                                        TypeManager.object_type);
+                                
                                RegisterHelperClass (impl_details_class);
                        }
 
index e6f8eeee053977017ab2a8e99f2391c66ae261cc..9f021bba6422ad8419e5c0249ef381c57a0b283d 100755 (executable)
@@ -2685,7 +2685,7 @@ namespace Mono.CSharp {
                                        continue;
 
                                VariableNames [i] = ip.ParameterName (i);
-                               VariableTypes [i] = ip.ParameterType (i).GetElementType ();
+                               VariableTypes [i] = TypeManager.GetElementType (ip.ParameterType (i));
 
                                map [i] = new VariableInfo (VariableNames [i], VariableTypes [i], i, Length);
                                Length += map [i].Length;
@@ -3352,7 +3352,8 @@ namespace Mono.CSharp {
                                                // but the fact is that you would not be able to use the pointer variable
                                                // *anyways*
                                                //
-                                               if (!TypeManager.VerifyUnManaged (variable_type.GetElementType (), vi.Location))
+                                               if (!TypeManager.VerifyUnManaged (TypeManager.GetElementType (variable_type),
+                                                                                  vi.Location))
                                                        continue;
                                        }
 
@@ -4622,7 +4623,7 @@ namespace Mono.CSharp {
                                // Case 2: Array
                                //
                                if (e.Type.IsArray){
-                                       Type array_type = e.Type.GetElementType ();
+                                       Type array_type = TypeManager.GetElementType (e.Type);
                                        
                                        vi.MakePinned ();
                                        //
@@ -5240,7 +5241,7 @@ namespace Mono.CSharp {
 
                        if (expr.Type.IsArray) {
                                array_type = expr.Type;
-                               element_type = array_type.GetElementType ();
+                               element_type = TypeManager.GetElementType (array_type);
 
                                empty = new EmptyExpression (element_type);
                        } else {
index 16b35b04b96f2e0922cfde48ee215c43effa3135..c93be326bf6fa2bd413bc4004354cc692f06a02d 100755 (executable)
@@ -77,7 +77,7 @@ namespace Mono.CSharp {
 
                        Type partype = ParameterType (pos);
                        if (partype.IsByRef){
-                               partype = partype.GetElementType ();
+                               partype = TypeManager.GetElementType (partype);
                                if (pi [pos].IsOut)
                                        sb.Append ("out ");
                                else
index c907a3d718b35f714a048491e2344938aae6606b..326e22f66ea1dab420dea22c394e2b5badbe8f94 100755 (executable)
@@ -578,10 +578,10 @@ public class TypeManager {
 
                foreach (ModuleBuilder mb in modules) {
                        t = mb.GetType (name);
-                       if (t != null){
+                       if (t != null) 
                                return t;
-                       }
                }
+                        
                return null;
        }
 
@@ -1213,6 +1213,8 @@ public class TypeManager {
        private static MemberList MemberLookup_FindMembers (Type t, MemberTypes mt, BindingFlags bf,
                                                            string name, out bool used_cache)
        {
+                bool not_loaded_corlib = (t.Assembly == CodeGen.AssemblyBuilder);
+                
                //
                // We have to take care of arrays specially, because GetType on
                // a TypeBuilder array will return a Type, not a TypeBuilder,
@@ -1399,6 +1401,18 @@ public class TypeManager {
                return false;
        }
 
+        //
+        // Do the right thing when returning the element type of
+        // an array type based on whether we 
+        //
+        public static Type GetElementType (Type t)
+        {
+                if (RootContext.StdLib)
+                        return t.GetElementType ();
+                else
+                        return TypeToCoreType (t.GetElementType ());
+        }
+
        /// <summary>
        ///   Returns the User Defined Types
        /// </summary>
@@ -1663,7 +1677,8 @@ public class TypeManager {
                return true;
        }
 
-       static public bool RegisterIndexer (PropertyBuilder pb, MethodBase get, MethodBase set, Type[] args)
+       static public bool RegisterIndexer (PropertyBuilder pb, MethodBase get,
+                                            MethodBase set, Type[] args)
        {
                if (!RegisterProperty (pb, get,set))
                        return false;
@@ -2470,9 +2485,9 @@ public class TypeManager {
                        mt &= (MemberTypes.Method | MemberTypes.Constructor);
                } while (searching);
 
-               if (method_list != null && method_list.Count > 0)
-                       return (MemberInfo []) method_list.ToArray (typeof (MemberInfo));
-
+               if (method_list != null && method_list.Count > 0) {
+                        return (MemberInfo []) method_list.ToArray (typeof (MemberInfo));
+                }
                //
                // This happens if we already used the cache in the first iteration, in this case
                // the cache already looked in all interfaces.