if (right.IsNull)
return ReducedExpression.Create (left, this);
- if (Convert.ImplicitConversionExists (ec, right, unwrap.Type)) {
- left = unwrap;
- ltype = left.Type;
+ Expression conv;
+ if (right.Type.IsNullableType) {
+ conv = right.Type == ltype ? right : Convert.ImplicitNulableConversion (ec, right, ltype);
+ if (conv != null) {
+ right = conv;
+ type = ltype;
+ return this;
+ }
+ } else {
+ conv = Convert.ImplicitConversion (ec, right, unwrap.Type, loc);
+ if (conv != null) {
+ left = unwrap;
+ ltype = left.Type;
- //
- // If right is a dynamic expression, the result type is dynamic
- //
- if (right.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
- type = right.Type;
+ //
+ // If right is a dynamic expression, the result type is dynamic
+ //
+ if (right.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
+ type = right.Type;
- // Need to box underlying value type
- left = Convert.ImplicitBoxingConversion (left, ltype, type);
+ // Need to box underlying value type
+ left = Convert.ImplicitBoxingConversion (left, ltype, type);
+ return this;
+ }
+
+ right = conv;
+ type = ltype;
return this;
}
-
- right = Convert.ImplicitConversion (ec, right, ltype, loc);
- type = ltype;
- return this;
}
} else if (TypeSpec.IsReferenceType (ltype)) {
if (Convert.ImplicitConversionExists (ec, right, ltype)) {
</method>\r
</type>\r
</test>\r
+ <test name="gtest-621.cs">\r
+ <type name="X">\r
+ <method name="Int32 Main()" attrs="145">\r
+ <size>267</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>7</size>\r
+ </method>\r
+ </type>\r
+ </test>\r
<test name="gtest-anontype-01.cs">\r
<type name="Test">\r
<method name="Int32 Main()" attrs="150">\r