2008-09-15 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Mon, 15 Sep 2008 13:08:20 +0000 (13:08 -0000)
committerMarek Safar <marek.safar@gmail.com>
Mon, 15 Sep 2008 13:08:20 +0000 (13:08 -0000)
A fix for bug #425601
* driver.cs, typemanager.cs, namespace.cs: Automatically reference
System.Core only when there is no custom ExtensionAttribute
implementation.

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

mcs/mcs/driver.cs
mcs/mcs/namespace.cs
mcs/mcs/typemanager.cs

index fc51eb88ea1c2d977d65a6edd37227eefe2d2c12..28d431a8dd82d41e4fa7f56d0747a2e5d63a52fc 100644 (file)
@@ -742,9 +742,17 @@ namespace Mono.CSharp
                                // even with -noconfig, otherwise the check for ExtensionAttribute in
                                // loaded assemblies won't work
                                //
-                               if (need_system_core && references.Count != 0 && Driver.OutputFile != "System.Core.dll")
-                                       soft_references.Add ("System.Core");
-                               
+
+                               if (need_system_core && references.Count != 0) {
+                                       //
+                                       // TODO: use TypeManager.CoreLookupType (...) when it stops defining types
+                                       // on your back
+                                       //
+                                       Namespace n = GlobalRootNamespace.Global.GetNamespace ("System.Runtime.CompilerServices", false);
+                                       if (n == null || !n.HasDefinition ("ExtensionAttribute")) {
+                                               soft_references.Add ("System.Core");
+                                       }
+                               }
                                return;
                        }
                        
index b2eb712580db2582bb92c781e5cc9753eda3319a..8dab8c83b5654bd38adbf4aef51aa05ce61a416a 100644 (file)
@@ -421,6 +421,11 @@ namespace Mono.CSharp {
                        return ns;
                }
 
+               public bool HasDefinition (string name)
+               {
+                       return declspaces != null && declspaces [name] != null;
+               }
+
                TypeExpr LookupType (string name, Location loc)
                {
                        if (cached_types.Contains (name))
index 3265896ce92ca99e6711c268cd5d48cadb89c589..bae1f15db52ffc3a7a4bb686923e179e4b8ebb9c 100644 (file)
@@ -1034,6 +1034,28 @@ namespace Mono.CSharp {
        //
        public static void InitOptionalCoreTypes ()
        {
+               system_string_expr.Type = string_type;
+               system_boolean_expr.Type = bool_type;
+               system_decimal_expr.Type = decimal_type;
+               system_single_expr.Type = float_type;
+               system_double_expr.Type = double_type;
+               system_sbyte_expr.Type = sbyte_type;
+               system_byte_expr.Type = byte_type;
+               system_int16_expr.Type = short_type;
+               system_uint16_expr.Type = ushort_type;
+               system_int32_expr.Type = int32_type;
+               system_uint32_expr.Type = uint32_type;
+               system_int64_expr.Type = int64_type;
+               system_uint64_expr.Type = uint64_type;
+               system_char_expr.Type = char_type;
+               system_void_expr.Type = void_type;
+
+               //
+               // These are only used for compare purposes
+               //
+               anonymous_method_type = typeof (AnonymousMethodBody);
+               null_type = typeof (NullLiteral);
+               
                void_ptr_type = GetPointerType (void_type);
                char_ptr_type = GetPointerType (char_type);
 
@@ -1132,28 +1154,6 @@ namespace Mono.CSharp {
                                        TypeManager.CSharpName (system_4_type_arg));
                        }
                }
-
-               system_string_expr.Type = string_type;
-               system_boolean_expr.Type = bool_type;
-               system_decimal_expr.Type = decimal_type;
-               system_single_expr.Type = float_type;
-               system_double_expr.Type = double_type;
-               system_sbyte_expr.Type = sbyte_type;
-               system_byte_expr.Type = byte_type;
-               system_int16_expr.Type = short_type;
-               system_uint16_expr.Type = ushort_type;
-               system_int32_expr.Type = int32_type;
-               system_uint32_expr.Type = uint32_type;
-               system_int64_expr.Type = int64_type;
-               system_uint64_expr.Type = uint64_type;
-               system_char_expr.Type = char_type;
-               system_void_expr.Type = void_type;
-
-               //
-               // These are only used for compare purposes
-               //
-               anonymous_method_type = typeof (AnonymousMethodBody);
-               null_type = typeof (NullLiteral);
        }
 
        const BindingFlags instance_and_static = BindingFlags.Static | BindingFlags.Instance;