bool ok = true;
//
- // The class constraint comes next.
+ // Check the class constraint
//
if (tparam.HasTypeConstraint) {
if (!CheckConversion (mc, context, atype, tparam, tparam.BaseType, loc)) {
}
//
- // Now, check the interfaces and type parameters constraints
+ // Check the interfaces constraints
//
if (tparam.Interfaces != null) {
if (TypeManager.IsNullableType (atype)) {
}
}
+ //
+ // Check the type parameter constraint
+ //
+ if (tparam.TypeArguments != null) {
+ foreach (var ta in tparam.TypeArguments) {
+ if (!CheckConversion (mc, context, atype, tparam, ta, loc)) {
+ if (mc == null)
+ return false;
+
+ ok = false;
+ }
+ }
+ }
+
//
// Finally, check the constructor constraint.
//
ms.returnType = inflator.Inflate (returnType);
ms.parameters = parameters.Inflate (inflator);
if (IsGeneric)
- ms.constraints = TypeParameterSpec.InflateConstraints (inflator, GenericDefinition.TypeParameters);
+ ms.constraints = TypeParameterSpec.InflateConstraints (inflator, Constraints);
return ms;
}