Author: martin
Date: 2006-06-15 17:54:41 -0400 (Thu, 15 Jun 2006)
New Revision: 61776

Modified:
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/class.cs
   trunk/mcs/gmcs/convert.cs
   trunk/mcs/gmcs/generic.cs
Log:
2006-06-15  Martin Baulig  <[EMAIL PROTECTED]>

        * class.cs (Operator.Define): Allow an implicit/explicit operator
        to convert to/from a nullable value of the enclosing type.

        * generic.cs (TypeManager.IsNullableTypeOf): New public method.
        (Nullable.Unwrap, Nullable.Wrap): Make these classes public.

        * convert.cs
        (Convert.ImplicitStandardConversionExists): Add support for lifted
        implicit/explicit conversions.
        (Convert.ImplicitConversionStandard): Likewise.



Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2006-06-15 21:21:12 UTC (rev 61775)
+++ trunk/mcs/gmcs/ChangeLog    2006-06-15 21:54:41 UTC (rev 61776)
@@ -1,3 +1,16 @@
+2006-06-15  Martin Baulig  <[EMAIL PROTECTED]>
+
+       * class.cs (Operator.Define): Allow an implicit/explicit operator
+       to convert to/from a nullable value of the enclosing type.
+
+       * generic.cs (TypeManager.IsNullableTypeOf): New public method.
+       (Nullable.Unwrap, Nullable.Wrap): Make these classes public.
+
+       * convert.cs
+       (Convert.ImplicitStandardConversionExists): Add support for lifted
+       implicit/explicit conversions.
+       (Convert.ImplicitConversionStandard): Likewise.
+
 2006-06-13  Martin Baulig  <[EMAIL PROTECTED]>
 
        * ecore.cs (SimpleName.DoSimpleNameResolve): Check whether we have

Modified: trunk/mcs/gmcs/class.cs
===================================================================
--- trunk/mcs/gmcs/class.cs     2006-06-15 21:21:12 UTC (rev 61775)
+++ trunk/mcs/gmcs/class.cs     2006-06-15 21:54:41 UTC (rev 61776)
@@ -7502,7 +7502,9 @@
                                        return false;
                                }
                                
-                               if (first_arg_type != declaring_type && 
return_type != declaring_type){
+                               if ((first_arg_type != declaring_type) && 
(return_type != declaring_type) &&
+                                   !TypeManager.IsNullableTypeOf 
(first_arg_type, declaring_type) &&
+                                   !TypeManager.IsNullableTypeOf (return_type, 
declaring_type)) {
                                        Report.Error (
                                                556, Location, 
                                                "User-defined conversion must 
convert to or from the " +

Modified: trunk/mcs/gmcs/convert.cs
===================================================================
--- trunk/mcs/gmcs/convert.cs   2006-06-15 21:21:12 UTC (rev 61775)
+++ trunk/mcs/gmcs/convert.cs   2006-06-15 21:54:41 UTC (rev 61776)
@@ -752,7 +752,7 @@
                                        }
                                }
                        }
-                       
+
                        if (ImplicitReferenceConversionExists (expr, 
target_type))
                                return true;
 
@@ -824,6 +824,9 @@
                        if (TypeManager.IsNullableType (expr_type) && 
TypeManager.IsNullableType (target_type))
                                return true;
 
+                       if (TypeManager.IsNullableTypeOf (target_type, 
expr_type))
+                               return true;                    
+
                        if (expr_type == TypeManager.anonymous_method_type){
                                if (!TypeManager.IsDelegateType (target_type))
                                        return false;
@@ -1163,7 +1166,7 @@
 
                        if (method == null)
                                return null;
-                       
+
                        Type most_specific_source = 
TypeManager.GetParameterData (method).ParameterType (0);
 
                        //
@@ -1300,6 +1303,9 @@
                                        return new EmptyCast (NullPointer.Null, 
target_type);
                        }
 
+                       if (TypeManager.IsNullableTypeOf (target_type, 
expr_type))
+                               return new Nullable.Wrap (expr, loc).Resolve 
(ec);
+
                        if (expr_type == TypeManager.anonymous_method_type){
                                if (!TypeManager.IsDelegateType (target_type)){
                                        Report.Error (1660, loc,

Modified: trunk/mcs/gmcs/generic.cs
===================================================================
--- trunk/mcs/gmcs/generic.cs   2006-06-15 21:21:12 UTC (rev 61775)
+++ trunk/mcs/gmcs/generic.cs   2006-06-15 21:54:41 UTC (rev 61776)
@@ -2655,6 +2655,14 @@
                        return generic_nullable_type == 
DropGenericTypeArguments (t);
                }
 
+               public static bool IsNullableTypeOf (Type t, Type nullable)
+               {
+                       if (!IsNullableType (t))
+                               return false;
+
+                       return GetTypeArguments (t) [0] == nullable;
+               }
+
                public static bool IsNullableValueType (Type t)
                {
                        if (!IsNullableType (t))
@@ -2688,7 +2696,7 @@
                        }
                }
 
-               protected class Unwrap : Expression, IMemoryLocation, 
IAssignMethod
+               public class Unwrap : Expression, IMemoryLocation, IAssignMethod
                {
                        Expression expr;
                        NullableInfo info;
@@ -2799,7 +2807,7 @@
                        }
                }
 
-               protected class Wrap : Expression
+               public class Wrap : Expression
                {
                        Expression expr;
                        NullableInfo info;

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

Reply via email to