2004-10-04 Miguel de Icaza <miguel@ximian.com>
authorMiguel de Icaza <miguel@gnome.org>
Mon, 4 Oct 2004 20:43:48 +0000 (20:43 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Mon, 4 Oct 2004 20:43:48 +0000 (20:43 -0000)
* ecore.cs (Expression.Constantity): Add support for turning null
into a constant.

* const.cs (Const.Define): Allow constants to be reference types
as long as the value is Null.

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

mcs/mcs/ChangeLog
mcs/mcs/const.cs
mcs/mcs/ecore.cs

index 4546886582e1c14c6de6b206420c0f11de704701..34510bd1b1b0fd6fff76727c30454eb0ccbae26e 100755 (executable)
@@ -1,3 +1,11 @@
+2004-10-04  Miguel de Icaza  <miguel@ximian.com>
+
+       * ecore.cs (Expression.Constantity): Add support for turning null
+       into a constant.
+
+       * const.cs (Const.Define): Allow constants to be reference types
+       as long as the value is Null.
+
 2004-10-04  Juraj Skripsky  <js@hotfeet.ch>
 
        * namespace.cs (NamespaceEntry.Using): No matter which warning
index f3fece7deba6cec9581d4c08c1f2cfc5a246ee52..1e0b00b2f44f83f886b5cc44c98920c570d88faa 100755 (executable)
@@ -82,8 +82,7 @@ namespace Mono.CSharp {
                        while (ttype.IsArray)
                            ttype = TypeManager.GetElementType (ttype);
                        
-                       if (!TypeManager.IsBuiltinType (ttype) &&
-                           (!ttype.IsSubclassOf (TypeManager.enum_type))) {
+                       if (!TypeManager.IsBuiltinType (ttype) && (!ttype.IsSubclassOf (TypeManager.enum_type)) && !(Expr is NullLiteral)) {
                                Report.Error (
                                        -3, Location,
                                        "Constant type is not valid (only system types are allowed)");
index 4bca8acf574c86f6f8aa55a71151d0eac12dd296..1aec0d95daadb6345427bfde7f2a53fa0c81d586 100755 (executable)
@@ -492,6 +492,8 @@ namespace Mono.CSharp {
                                Constant e = Constantify (v, real_type);
 
                                return new EnumConstant (e, t);
+                       } else if (v == null && !TypeManager.IsValueType (t)){
+                               return NullLiteral.Null;
                        } else
                                throw new Exception ("Unknown type for constant (" + t +
                                                     "), details: " + v);