//
// User operator is of T?
//
- if (t_x.IsNullableType && target.IsNullableType) {
+ if (t_x.IsNullableType && (target.IsNullableType || !implicitOnly)) {
//
// User operator return type does not match target type we need
// yet another conversion. This should happen for promoted numeric
if (source == null)
return null;
- source = new Nullable.LiftedConversion (source, unwrap, target).Resolve (ec);
+ if (target.IsNullableType)
+ source = new Nullable.LiftedConversion (source, unwrap, target).Resolve (ec);
}
} else {
source = implicitOnly ?
--- /dev/null
+using System;
+
+public class A<T>
+{
+ T value;
+
+ public A (T value)
+ {
+ this.value = value;
+ }
+
+ public static explicit operator T (A<T> source)
+ {
+ return source.value;
+ }
+}
+
+public class Test
+{
+ public static int Main ()
+ {
+ var source = new A<int?> (3);
+ if (N ((int)source) != 3)
+ return 1;
+
+ return 0;
+ }
+
+ static int N (int value)
+ {
+ return value;
+ }
+}
\ No newline at end of file