[Mono-bugs] [Bug 24390] New - Explicit/implicit user conversions bug

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
8 May 2002 04:45:49 -0000


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 miguel@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=24390

--- shadow/24390	Wed May  8 00:45:49 2002
+++ shadow/24390.tmp.2248	Wed May  8 00:45:49 2002
@@ -0,0 +1,63 @@
+Bug#: 24390
+Product: Mono/MCS
+Version: unspecified
+OS: other
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: miguel@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Explicit/implicit user conversions bug
+
+FindMostEncompassedType and FindMostEncompassingType are both wrong.  The
+following sample shows a problem with it.  Those routines are not computing
+the best Type based on the match criteria, they do give preference for one
+of the types.
+
+class Value {
+	public static explicit operator int (Value val)
+	{
+		return 1;
+	}
+
+	public static explicit operator MyObject (Value val)
+	{
+		return new MyObject (1);
+	}	
+
+	public static explicit operator uint (Value val)
+	{
+		return 1;
+	}
+}
+
+class MyObject {
+	public MyObject (int i) {}
+}
+
+class Derived : MyObject {
+	public Derived (int i) : base (i) { }
+
+	Derived Blah ()
+	{
+		Value val = new Value ();
+
+		return (Derived) val;
+	}
+}
+
+class Test {
+	static void Main ()
+	{
+		Value v = new Value ();
+
+		Derived d = (Derived) v;
+	}
+}