Author: marek
Date: 2007-01-02 06:47:40 -0500 (Tue, 02 Jan 2007)
New Revision: 70344

Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/attribute.cs
   trunk/mcs/mcs/namespace.cs
   trunk/mcs/mcs/report.cs
   trunk/mcs/mcs/rootcontext.cs
   trunk/mcs/mcs/typemanager.cs
Log:
2007-01-02  Marek Safar  <[EMAIL PROTECTED]>

        A fix for bug #80381
        * attribute.cs (AttributeTester.RegisterNonObsoleteType): Registers
        the core types.

        * namespace.cs (GlobalRootNamespace.LookupTypeReflection): Better error
        messages.
        (Namespace.LookupType): Always use core types from corlib when 
speficied.

        * report.cs: A new warning.

        * rootcontext.cs (BootstrapCorlib_ResolveInterface,
        BootstrapCorlib_ResolveClass): Register type as non-obsolete type.
        (ResolveCore): Add missing System.Runtime.InteropServices._Attribute.

        * typemanager.cs (CoreLookupType): Register type as non-obsolete type.
        (InitCoreTypes): Set expression type of object_type and value_type
        immediately after lookup.

Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2007-01-02 11:29:47 UTC (rev 70343)
+++ trunk/mcs/mcs/ChangeLog     2007-01-02 11:47:40 UTC (rev 70344)
@@ -1,3 +1,23 @@
+2007-01-02  Marek Safar  <[EMAIL PROTECTED]>
+
+       A fix for bug #80381
+       * attribute.cs (AttributeTester.RegisterNonObsoleteType): Registers
+       the core types.
+
+       * namespace.cs (GlobalRootNamespace.LookupTypeReflection): Better error
+       messages.
+       (Namespace.LookupType): Always use core types from corlib when 
speficied.
+
+       * report.cs: A new warning.
+
+       * rootcontext.cs (BootstrapCorlib_ResolveInterface,
+       BootstrapCorlib_ResolveClass): Register type as non-obsolete type.
+       (ResolveCore): Add missing System.Runtime.InteropServices._Attribute.
+
+       * typemanager.cs (CoreLookupType): Register type as non-obsolete type.
+       (InitCoreTypes): Set expression type of object_type and value_type
+       immediately after lookup.
+
 2007-01-01  Miguel de Icaza  <[EMAIL PROTECTED]>
 
        * cs-tokenizer.cs: Accept Pc class characters (Connector

Modified: trunk/mcs/mcs/attribute.cs
===================================================================
--- trunk/mcs/mcs/attribute.cs  2007-01-02 11:29:47 UTC (rev 70343)
+++ trunk/mcs/mcs/attribute.cs  2007-01-02 11:47:40 UTC (rev 70344)
@@ -1741,6 +1741,13 @@
                        return 
((CLSCompliantAttribute)CompliantAttribute[0]).IsCompliant;
                }
 
+               // Registers the core type as we assume that they will never be 
obsolete which
+               // makes things easier for bootstrap and faster (we don't need 
to query Obsolete attribute).
+               public static void RegisterNonObsoleteType (Type type)
+               {
+                       analyzed_types_obsolete [type] = FALSE;
+               }
+
                /// <summary>
                /// Returns instance of ObsoleteAttribute when type is obsolete
                /// </summary>
@@ -1754,7 +1761,7 @@
                                return (ObsoleteAttribute)type_obsolete;
 
                        ObsoleteAttribute result = null;
-                       if (type.IsByRef || type.IsArray || type.IsPointer) {
+                       if (TypeManager.HasElementType (type)) {
                                result = GetObsoleteAttribute 
(TypeManager.GetElementType (type));
                        } else if (TypeManager.IsGenericParameter (type) || 
TypeManager.IsGenericType (type))
                                return null;
@@ -1767,9 +1774,7 @@
                                        if (attribute.Length == 1)
                                                result = 
(ObsoleteAttribute)attribute [0];
                                } else {
-                                       // Is null during corlib bootstrap
-                                       if (TypeManager.obsolete_attribute_type 
!= null)
-                                               result = 
type_ds.GetObsoleteAttribute ();
+                                       result = type_ds.GetObsoleteAttribute 
();
                                }
                        }
 

Modified: trunk/mcs/mcs/namespace.cs
===================================================================
--- trunk/mcs/mcs/namespace.cs  2007-01-02 11:29:47 UTC (rev 70343)
+++ trunk/mcs/mcs/namespace.cs  2007-01-02 11:47:40 UTC (rev 70344)
@@ -224,11 +224,17 @@
                                                found_type = t;
                                                continue;
                                        }
-                                       
+
+                                       Report.SymbolRelatedToPreviousError 
(found_type);
+                                       if (loc.IsNull) {
+                                               DeclSpace ds = 
TypeManager.LookupDeclSpace (t);
+                                               Report.Warning (1685, 1, 
ds.Location, "The type `{0}' conflicts with the predefined type `{1}' and will 
be ignored",
+                                                       ds.GetSignatureForError 
(), TypeManager.CSharpName (found_type));
+                                               return found_type;
+                                       }
                                        Report.SymbolRelatedToPreviousError (t);
-                                       Report.SymbolRelatedToPreviousError 
(found_type);
-                                       Report.Warning (436, 2, loc, "Ignoring 
imported type `{0}' since the current assembly already has a declaration with 
the same name",
-                                               TypeManager.CSharpName (t));
+                                       Report.Warning (436, 2, loc, "The type 
`{0}' conflicts with the imported type `{1}'. Ignoring the imported type 
definition",
+                                               TypeManager.CSharpName (t), 
TypeManager.CSharpName (found_type));
                                        return t;
                                }
                        }
@@ -398,7 +404,9 @@
                        }
                        string lookup = t != null ? t.FullName : 
(fullname.Length == 0 ? name : fullname + "." + name);
                        Type rt = root.LookupTypeReflection (lookup, loc);
-                       if (t == null)
+
+                       // HACK: loc.IsNull when the type is core type
+                       if (t == null || (rt != null && loc.IsNull))
                                t = rt;
 
                        TypeExpr te = t == null ? null : new TypeExpression (t, 
Location.Null);

Modified: trunk/mcs/mcs/report.cs
===================================================================
--- trunk/mcs/mcs/report.cs     2007-01-02 11:29:47 UTC (rev 70343)
+++ trunk/mcs/mcs/report.cs     2007-01-02 11:47:40 UTC (rev 70344)
@@ -81,7 +81,7 @@
                        809,
                        1030,
                        1522, 1570, 1571, 1572, 1573, 1574, 1580, 1581, 1584, 
1587, 1589, 1590, 1591, 1592,
-                       1616, 1633, 1634, 1635, 1690, 1691, 1692,
+                       1616, 1633, 1634, 1635, 1685, 1690, 1691, 1692,
                        1717, 1718, 1720,
                        1901,
                        2002, 2023,

Modified: trunk/mcs/mcs/rootcontext.cs
===================================================================
--- trunk/mcs/mcs/rootcontext.cs        2007-01-02 11:29:47 UTC (rev 70343)
+++ trunk/mcs/mcs/rootcontext.cs        2007-01-02 11:47:40 UTC (rev 70344)
@@ -191,7 +191,7 @@
                //
                // Resolves a single class during the corlib bootstrap process
                //
-               static TypeBuilder BootstrapCorlib_ResolveClass (TypeContainer 
root, string name)
+               static Type BootstrapCorlib_ResolveClass (TypeContainer root, 
string name)
                {
                        object o = root.GetDefinition (name);
                        if (o == null){
@@ -210,7 +210,10 @@
                                return null;
                        }
 
-                       return ((DeclSpace) o).DefineType ();
+                       Type t = ((DeclSpace) o).DefineType ();
+                       if (t != null)
+                               AttributeTester.RegisterNonObsoleteType (t);
+                       return t;
                }
 
                //
@@ -260,7 +263,9 @@
                                return;
                        }
 
-                       ((DeclSpace) o).DefineType ();
+                       Type t = ((DeclSpace) o).DefineType ();
+                       if (t != null)
+                               AttributeTester.RegisterNonObsoleteType (t);
                }
 
                //
@@ -292,7 +297,13 @@
                        TypeManager.system_object_expr.Type = 
TypeManager.object_type;
                        TypeManager.value_type = BootstrapCorlib_ResolveClass 
(root, "System.ValueType");
                        TypeManager.system_valuetype_expr.Type = 
TypeManager.value_type;
+
+                       //
+                       // The core attributes
+                       //
+                       BootstrapCorlib_ResolveInterface (root, 
"System.Runtime.InteropServices._Attribute");
                        TypeManager.attribute_type = 
BootstrapCorlib_ResolveClass (root, "System.Attribute");
+                       TypeManager.obsolete_attribute_type = 
BootstrapCorlib_ResolveClass (root, "System.ObsoleteAttribute");
                        TypeManager.indexer_name_type = 
BootstrapCorlib_ResolveClass (root, 
"System.Runtime.CompilerServices.IndexerNameAttribute");
                        
                        string [] interfaces_first_stage = {
@@ -390,7 +401,6 @@
                                
"System.Runtime.CompilerServices.FixedBufferAttribute",
 #endif
                                "System.Diagnostics.ConditionalAttribute",
-                               "System.ObsoleteAttribute",
                                "System.ParamArrayAttribute",
                                "System.CLSCompliantAttribute",
                                "System.Security.UnverifiableCodeAttribute",

Modified: trunk/mcs/mcs/typemanager.cs
===================================================================
--- trunk/mcs/mcs/typemanager.cs        2007-01-02 11:29:47 UTC (rev 70343)
+++ trunk/mcs/mcs/typemanager.cs        2007-01-02 11:47:40 UTC (rev 70344)
@@ -853,8 +853,12 @@
                Namespace ns = RootNamespace.Global.GetNamespace (ns_name, 
true);
                FullNamedExpression fne = ns.Lookup (RootContext.ToplevelTypes, 
name, Location.Null);
                Type t = fne == null ? null : fne.Type;
-               if (t == null)
+               if (t == null) {
                        Report.Error (518, "The predefined type `" + name + "' 
is not defined or imported");
+                       return null;
+               }
+
+               AttributeTester.RegisterNonObsoleteType (t);
                return t;
        }
 
@@ -983,7 +987,9 @@
        public static void InitCoreTypes ()
        {
                object_type   = CoreLookupType ("System", "Object");
+               system_object_expr.Type = object_type;
                value_type    = CoreLookupType ("System", "ValueType");
+               system_valuetype_expr.Type = value_type;
 
                InitEnumUnderlyingTypes ();
 
@@ -1134,7 +1140,6 @@
                        }
                }
 
-               system_object_expr.Type = object_type;
                system_string_expr.Type = string_type;
                system_boolean_expr.Type = bool_type;
                system_decimal_expr.Type = decimal_type;
@@ -1152,7 +1157,6 @@
                system_void_expr.Type = void_type;
                system_asynccallback_expr.Type = asynccallback_type;
                system_iasyncresult_expr.Type = iasyncresult_type;
-               system_valuetype_expr.Type = value_type;
 
                //
                // These are only used for compare purposes

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

Reply via email to