* expression.cs: Implicity convert the result from UserCast.
Include the test from Ravi that exhibits the bug.
New classes from Toelen.
svn path=/trunk/mcs/; revision=1102
+2001-10-05 Miguel de Icaza <miguel@ximian.com>
+
+ * expression.cs: Implicity convert the result from UserCast.
+
2001-10-05 Ravi Pratap <ravi@ximian.com>
* expression.cs (Expression::FindMostEncompassingType): Fix bug which
return name;
}
+
+ string TrimExt (string name)
+ {
+ int pos = name.LastIndexOf (".");
+
+ return name.Substring (0, pos);
+ }
public CodeGen (string name, string output)
{
AssemblyName an;
an = new AssemblyName ();
- an.Name = name;
+ an.Name = TrimExt (name);
current_domain = AppDomain.CurrentDomain;
assembly_builder = current_domain.DefineDynamicAssembly (
an, AssemblyBuilderAccess.RunAndSave);
bool ProbeCollectionType (Type t)
{
+
return true;
}
{
Expression mg1 = null, mg2 = null, mg3 = null, mg4 = null;
Expression mg5 = null, mg6 = null, mg7 = null, mg8 = null;
+ Expression e;
MethodBase method = null;
Type source_type = source.Type;
return null;
}
+ //
+ // This will do the conversion to the best match that we
+ // found. Now we need to perform an implict standard conversion
+ // if the best match was not the type that we were requested
+ // by target.
+ //
+ e = new UserCast ((MethodInfo) method, source, most_specific_source,
+ most_specific_target, look_for_explicit);
- return new UserCast ((MethodInfo) method, source, most_specific_source,
- most_specific_target, look_for_explicit);
-
+ if (e.Type != target){
+ e = ConvertImplicitStandard (tc, e, target, l);
+ return e;
+ } else
+ return e;
}
return null;
TEST_SOURCES = \
test-1 test-2 test-3 test-4 test-6 test-7 test-8 test-9 test-10 \
- test-11 test-12 test-13 test-16 test-20
+ test-11 test-12 test-13 test-16 test-17 test-20
TEST_NOPASS = \
test-5
--- /dev/null
+//
+// This test excercises user defined conversions and an implicit
+// conversion to a type afterwards.
+//
+//
+using System;
+
+class Blah {
+
+ public static int Main ()
+ {
+ Blah k = new Blah ();
+
+ float f = k;
+
+ if (f == 2){
+ Console.WriteLine ("Best implicit operator selected correctly");
+ return 0;
+ }
+ return 1;
+
+ }
+
+ public static implicit operator byte (Blah i)
+ {
+ Console.WriteLine ("Blah->byte");
+ return 0;
+ }
+
+
+ public static implicit operator short (Blah i)
+ {
+ Console.WriteLine ("Blah->short");
+ return 1;
+ }
+
+ public static implicit operator int (Blah i)
+ {
+ Console.WriteLine ("Blah->int");
+ return 2;
+ }
+
+
+}
+