diff options
Diffstat (limited to 'mcs/gmcs/generic.cs')
-rw-r--r-- | mcs/gmcs/generic.cs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/mcs/gmcs/generic.cs b/mcs/gmcs/generic.cs index b40828e742a..58a967e1029 100644 --- a/mcs/gmcs/generic.cs +++ b/mcs/gmcs/generic.cs @@ -1495,7 +1495,7 @@ namespace Mono.CSharp { is_class = is_struct = false; } } else { - is_class = atype.IsClass || atype.IsInterface; + is_class = atype.IsClass; is_struct = atype.IsValueType && !TypeManager.IsNullableType (atype); } @@ -1526,16 +1526,26 @@ namespace Mono.CSharp { // The class constraint comes next. // if (gc.HasClassConstraint) { - if (!CheckConstraint (ec, ptype, aexpr, gc.ClassConstraint)) + if (!CheckConstraint (ec, ptype, aexpr, gc.ClassConstraint)) { + Error_TypeMustBeConvertible (atype, gc.ClassConstraint, ptype); return false; + } } // // Now, check the interface constraints. // foreach (Type it in gc.InterfaceConstraints) { - if (!CheckConstraint (ec, ptype, aexpr, it)) + Type itype; + if (it.IsGenericParameter) + itype = atypes [it.GenericParameterPosition]; + else + itype = it; + + if (!CheckConstraint (ec, ptype, aexpr, itype)) { + Error_TypeMustBeConvertible (atype, itype, ptype); return false; + } } // @@ -1590,11 +1600,7 @@ namespace Mono.CSharp { ctype = atypes [pos]; } - if (Convert.ImplicitStandardConversionExists (ec, expr, ctype)) - return true; - - Error_TypeMustBeConvertible (expr.Type, ctype, ptype); - return false; + return Convert.ImplicitStandardConversionExists (ec, expr, ctype); } bool HasDefaultConstructor (EmitContext ec, Type atype) |