Author: raja
Date: 2005-10-11 08:07:13 -0400 (Tue, 11 Oct 2005)
New Revision: 51560

Modified:
   trunk/mcs/errors/known-issues-gmcs
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/convert.cs
   trunk/mcs/gmcs/ecore.cs
   trunk/mcs/tests/known-issues-gmcs
Log:
*** Merged revisions from mcs: 51396, 51403, 51548


Modified: trunk/mcs/errors/known-issues-gmcs
===================================================================
--- trunk/mcs/errors/known-issues-gmcs  2005-10-11 11:47:55 UTC (rev 51559)
+++ trunk/mcs/errors/known-issues-gmcs  2005-10-11 12:07:13 UTC (rev 51560)
@@ -13,7 +13,6 @@
 
 cs0229-2.cs
 cs0229.cs NO ERROR
-cs0266-8.cs NO ERROR
 cs0525.cs
 cs0526.cs
 cs0547-2.cs # new in GMCS; grammar issue

Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2005-10-11 11:47:55 UTC (rev 51559)
+++ trunk/mcs/gmcs/ChangeLog    2005-10-11 12:07:13 UTC (rev 51560)
@@ -1,6 +1,27 @@
+2005-10-11  Marek Safar  <[EMAIL PROTECTED]>
+
+       Fix #76370.
+       * convert.cs (ExplicitConversionCore): Fixed object->enum
+       conversion.
+
+2005-10-07  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       Fix #76323.
+       * convert.cs (ImplicitConversionStandard): Move conversion of
+       void* to arbitrary pointer types ...
+       (ExplicitConversionStandard): .. here.
+       * ecore.cs (Expression.Error_ValueCannotBeConverted): Fix CS0266
+       error to always print typenames.
+
+2005-10-07  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       * convert.cs (GetConversionOperator): Rename from
+       GetConversionOperators.  Move operator selection code from ...
+       (UserDefinedConversion): ... here.
+
 2005-10-06  Marek Safar  <[EMAIL PROTECTED]>
 
-       * convert.cs(ExplicitConversionCore): Removed duplicate enum
+       * convert.cs (ExplicitConversionCore): Removed duplicate enum
        conversion.
 
 2005-10-05  Marek Safar  <[EMAIL PROTECTED]>

Modified: trunk/mcs/gmcs/convert.cs
===================================================================
--- trunk/mcs/gmcs/convert.cs   2005-10-11 11:47:55 UTC (rev 51559)
+++ trunk/mcs/gmcs/convert.cs   2005-10-11 12:07:13 UTC (rev 51560)
@@ -1044,42 +1044,60 @@
                }
 
                /// <summary>
-               ///   Computes the list of the user-defined conversion
-               ///   operators from source_type to target_type.  
`look_for_explicit'
-               ///   controls whether we should also include the list of 
explicit
-               ///   operators
+               ///   Compute the user-defined conversion operator from 
source_type to target_type. 
+               ///   `look_for_explicit' controls whether we should also 
include the list of explicit operators
                /// </summary>
-               static IList GetConversionOperators (EmitContext ec,
-                                                    Expression source, Type 
target_type,
-                                                    Location loc, bool 
look_for_explicit)
+               static MethodInfo GetConversionOperator (EmitContext ec, 
Expression source, Type target_type, bool look_for_explicit)
                {
-                       ArrayList ret = new ArrayList (4);
+                       ArrayList ops = new ArrayList (4);
 
                        Type source_type = source.Type;
 
                        if (source_type != TypeManager.decimal_type) {
-                               AddConversionOperators (ec, ret, source, 
target_type, look_for_explicit,
-                                       Expression.MethodLookup (
-                                               ec, source_type, "op_Implicit", 
loc) as MethodGroupExpr);
+                               AddConversionOperators (ec, ops, source, 
target_type, look_for_explicit,
+                                       Expression.MethodLookup (ec, 
source_type, "op_Implicit", Location.Null) as MethodGroupExpr);
                                if (look_for_explicit) {
-                                       AddConversionOperators (ec, ret, 
source, target_type, look_for_explicit,
+                                       AddConversionOperators (ec, ops, 
source, target_type, look_for_explicit,
                                                Expression.MethodLookup (
-                                                       ec, source_type, 
"op_Explicit", loc) as MethodGroupExpr);
+                                                       ec, source_type, 
"op_Explicit", Location.Null) as MethodGroupExpr);
                                }
                        }
 
                        if (target_type != TypeManager.decimal_type) {
-                               AddConversionOperators (ec, ret, source, 
target_type, look_for_explicit,
-                                       Expression.MethodLookup (
-                                               ec, target_type, "op_Implicit", 
loc) as MethodGroupExpr);
+                               AddConversionOperators (ec, ops, source, 
target_type, look_for_explicit,
+                                       Expression.MethodLookup (ec, 
target_type, "op_Implicit", Location.Null) as MethodGroupExpr);
                                if (look_for_explicit) {
-                                       AddConversionOperators (ec, ret, 
source, target_type, look_for_explicit,
+                                       AddConversionOperators (ec, ops, 
source, target_type, look_for_explicit,
                                                Expression.MethodLookup (
-                                                       ec, target_type, 
"op_Explicit", loc) as MethodGroupExpr);
+                                                       ec, target_type, 
"op_Explicit", Location.Null) as MethodGroupExpr);
                                }
                        }
 
-                       return ret;
+                       if (ops.Count == 0)
+                               return null;
+
+                       Type most_specific_source = FindMostSpecificSource (ec, 
ops, source, look_for_explicit);
+                       if (most_specific_source == null)
+                               return null;
+
+                       Type most_specific_target = FindMostSpecificTarget (ec, 
ops, target_type, look_for_explicit);
+                       if (most_specific_target == null)
+                               return null;
+
+                       MethodInfo method = null;
+
+                       foreach (MethodInfo m in ops) {
+                               if (m.ReturnType != most_specific_target)
+                                       continue;
+                               if (TypeManager.GetParameterData 
(m).ParameterType (0) != most_specific_source)
+                                       continue;
+                               // Ambiguous: more than one conversion operator 
satisfies the signature.
+                               if (method != null)
+                                       return null;
+                               method = m;
+                       }
+
+                       return method;
                }
 
                static DoubleHash explicit_conv = new DoubleHash (100);
@@ -1094,8 +1112,6 @@
                {
                        Type source_type = source.Type;
                        MethodInfo method = null;
-                       Type most_specific_source = null;
-                       Type most_specific_target = null;
 
                        if (TypeManager.IsNullableType (source_type) && 
TypeManager.IsNullableType (target))
                                return new Nullable.LiftedConversion (
@@ -1106,45 +1122,8 @@
 
                        if (!(source is Constant) && hash.Lookup (source_type, 
target, out o)) {
                                method = (MethodInfo) o;
-                               if (method != null) {
-                                       ParameterData pd = 
TypeManager.GetParameterData (method);
-                                       most_specific_source = pd.ParameterType 
(0);
-                                       most_specific_target = 
method.ReturnType;
-                               }
                        } else {
-                               IList ops = GetConversionOperators (ec, source, 
target, loc, look_for_explicit);
-                               if (ops == null || ops.Count == 0) {
-                                       method = null;
-                                       goto skip;
-                               }
-                                       
-                               most_specific_source = FindMostSpecificSource 
(ec, ops, source, look_for_explicit);
-                               if (most_specific_source == null) {
-                                       method = null;
-                                       goto skip;
-                               }
-                               
-                               most_specific_target = FindMostSpecificTarget 
(ec, ops, target, look_for_explicit);
-                               if (most_specific_target == null) {
-                                       method = null;
-                                       goto skip;
-                               }
-                               
-                               int count = 0;
-                               
-                               foreach (MethodInfo m in ops) {
-                                       ParameterData pd = 
TypeManager.GetParameterData (m);
-                                       
-                                       if (pd.ParameterType (0) == 
most_specific_source &&
-                                           m.ReturnType == 
most_specific_target) {
-                                               method = m;
-                                               count++;
-                                       }
-                               }
-                               if (count > 1)
-                                       method = null;
-                               
-                       skip:
+                               method = GetConversionOperator (ec, source, 
target, look_for_explicit);
                                if (!(source is Constant))
                                        hash.Insert (source_type, target, 
method);
                        }
@@ -1152,6 +1131,8 @@
                        if (method == null)
                                return null;
                        
+                       Type most_specific_source = 
TypeManager.GetParameterData (method).ParameterType (0);
+
                        //
                        // This will do the conversion to the best match that we
                        // found.  Now we need to perform an implict standard 
conversion
@@ -1284,13 +1265,8 @@
                                        }
                                }
                                
-                               if (target_type.IsPointer) {
-                                       if (expr_type == TypeManager.null_type)
-                                               return new EmptyCast 
(NullPointer.Null, target_type);
-
-                                       if (expr_type == 
TypeManager.void_ptr_type)
-                                               return new EmptyCast (expr, 
target_type);
-                               }
+                               if (expr_type == TypeManager.null_type && 
target_type.IsPointer)
+                                       return new EmptyCast (NullPointer.Null, 
target_type);
                        }
 
                        if (expr_type == TypeManager.anonymous_method_type){
@@ -1862,9 +1838,9 @@
                                return ne;
 
                        //
-                       // Unboxing conversion.
+                       // Unboxing conversions; only object types can be 
convertible to enum
                        //
-                       if (expr_type == TypeManager.object_type && 
target_type.IsValueType)
+                       if (expr_type == TypeManager.object_type && 
target_type.IsValueType || expr_type == TypeManager.enum_type)
                                return new UnboxCast (expr, target_type);
 
                        if (TypeManager.IsEnumType (expr_type)) {
@@ -1978,6 +1954,9 @@
                        if (ne != null)
                                return ne;
 
+                       if (ec.InUnsafe && expr.Type == 
TypeManager.void_ptr_type && target_type.IsPointer)
+                               return new EmptyCast (expr, target_type);
+
                        expr.Error_ValueCannotBeConverted (l, target_type, 
true);
                        return null;
                }

Modified: trunk/mcs/gmcs/ecore.cs
===================================================================
--- trunk/mcs/gmcs/ecore.cs     2005-10-11 11:47:55 UTC (rev 51559)
+++ trunk/mcs/gmcs/ecore.cs     2005-10-11 12:07:13 UTC (rev 51560)
@@ -302,7 +302,7 @@
 
                        if (b || Convert.ExplicitReferenceConversionExists 
(Type, target) || Convert.ExplicitUnsafe (e, target) != null) {
                                Report.Error (266, loc, "Cannot implicitly 
convert type `{0}' to `{1}'. An explicit conversion exists (are you missing a 
cast?)",
-                                       GetSignatureForError (), 
TypeManager.CSharpName (target));
+                                       TypeManager.CSharpName (Type), 
TypeManager.CSharpName (target));
                                return;
                        }
 

Modified: trunk/mcs/tests/known-issues-gmcs
===================================================================
--- trunk/mcs/tests/known-issues-gmcs   2005-10-11 11:47:55 UTC (rev 51559)
+++ trunk/mcs/tests/known-issues-gmcs   2005-10-11 12:07:13 UTC (rev 51560)
@@ -11,4 +11,3 @@
 test-67.cs IGNORE      # Windows-only test
 test-anon-27.cs
 test-xml-027.cs
-test-461.cs

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

Reply via email to