From: Miguel de Icaza Date: Mon, 4 Oct 2004 20:43:48 +0000 (-0000) Subject: 2004-10-04 Miguel de Icaza X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=6e26acaedb5eff0f59ab017ce849cfbc8c1b68a1;p=mono.git 2004-10-04 Miguel de Icaza * 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 --- diff --git a/mcs/mcs/ChangeLog b/mcs/mcs/ChangeLog index 4546886582e..34510bd1b1b 100755 --- a/mcs/mcs/ChangeLog +++ b/mcs/mcs/ChangeLog @@ -1,3 +1,11 @@ +2004-10-04 Miguel de Icaza + + * 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 * namespace.cs (NamespaceEntry.Using): No matter which warning diff --git a/mcs/mcs/const.cs b/mcs/mcs/const.cs index f3fece7deba..1e0b00b2f44 100755 --- a/mcs/mcs/const.cs +++ b/mcs/mcs/const.cs @@ -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)"); diff --git a/mcs/mcs/ecore.cs b/mcs/mcs/ecore.cs index 4bca8acf574..1aec0d95daa 100755 --- a/mcs/mcs/ecore.cs +++ b/mcs/mcs/ecore.cs @@ -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);