[Mono-bugs] [Bug 54928][Nor] Changed - implicit operator cannot
convert from struct to decimal
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Tue May 24 19:10:52 EDT 2005
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by duncan at ximian.com.
http://bugzilla.ximian.com/show_bug.cgi?id=54928
--- shadow/54928 2005-05-24 19:07:28.000000000 -0400
+++ shadow/54928.tmp.19055 2005-05-24 19:10:52.000000000 -0400
@@ -150,6 +150,47 @@
Sx: ObjectID | Tx: System.Decimal
54928.cs(26) error CS0029: Cannot convert implicitly from `ObjectID'
to `decimal'
I think U should include only the first 2 conversion operators, in
which case, Tx becomes "System.Int64", and not "System.Decimal".
+
+------- Additional Comments From duncan at ximian.com 2005-05-24 19:10 -------
+Continuing...
+
+This problem stems from the fact that Convert.GetConversionOperators
+calls "Expression.MethodLookup", looking for everything that is
+"op_Implicit". Instead, I think it should be calling something like
+this instead:
+
+static Expression GetUserDefinedConversionOperators (EmitContext ec,
+Type type,
+ string name, Location loc)
+{
+ MethodGroupExpr operators = Expression.MethodLookup (ec, type, name,
+loc) as MethodGroupExpr;
+
+ if (operators == null)
+ return null;
+
+ Console.WriteLine ("#1");
+ MethodInfo [] user_defined = new MethodInfo [operators.Methods.Length];
+ Console.WriteLine ("#2");
+ int i = 0;
+ foreach (MethodInfo o in operators.Methods) {
+ Type s = TypeManager.GetParameterData (o).ParameterType (0);
+ if (s == null)
+ continue;
+ Expression expr = new EmptyExpression (s);
+ if (ImplicitStandardConversionExists (ec, expr, o.ReturnType))
+ continue;
+ user_defined [i] = o;
+ i++;
+ }
+
+ return new MethodGroupExpr (user_defined, loc);
+}
+
+I'm using ImplicitStandardConversionExists here as a filter to retain
+only user-defined conversion operators. Is there a better way than
+this? Also, it doesn't work right now because ISCE expects an
+Expression, but all I've got is a Type.
More information about the mono-bugs
mailing list