return true;
}
- public TypeExpr[] InterfaceConstraints {
- get {
- TypeExpr[] ifaces = new TypeExpr [iface_constraints.Count];
- iface_constraints.CopyTo (ifaces, 0);
- return ifaces;
- }
- }
-
public bool ResolveTypes (EmitContext ec)
{
iface_constraint_types = new Type [iface_constraints.Count];
public void Define (GenericTypeParameterBuilder type)
{
this.type = type;
- TypeExpr[] ifaces = null;
- if (constraints != null) {
- ifaces = constraints.InterfaceConstraints;
+ Type[] ifaces = null;
+ if (constraints != null)
constraints.Define (type);
- }
- TypeManager.AddTypeParameter (type, this, ifaces);
+ TypeManager.AddTypeParameter (type, this);
}
public bool DefineType (EmitContext ec)
type.SetBaseTypeConstraint (gc.ClassConstraint);
type.SetInterfaceConstraints (gc.InterfaceConstraints);
+ TypeManager.RegisterBuilder (type, gc.InterfaceConstraints);
}
return true;
if (TypeManager.HasGenericArguments (ctype)) {
Type[] types = TypeManager.GetTypeArguments (ctype);
- TypeArguments args = new TypeArguments (loc);
+ TypeArguments new_args = new TypeArguments (loc);
for (int i = 0; i < types.Length; i++) {
- Type t = types [i] == ptype ? expr.Type : types [i];
- args.Add (new TypeExpression (t, loc));
+ Type t = types [i];
+
+ if (t.IsGenericParameter) {
+ int pos = t.GenericParameterPosition;
+ t = args.Arguments [pos];
+ }
+ new_args.Add (new TypeExpression (t, loc));
}
- ctype = new ConstructedType (ctype, args, loc).ResolveType (ec);
+ ctype = new ConstructedType (ctype, new_args, loc).ResolveType (ec);
if (ctype == null)
return false;
}
//
// Now, check the interface constraints.
//
- foreach (TypeExpr iface in TypeManager.GetInterfaces (ptype)) {
- Type itype = iface.ResolveType (ec);
- if (itype == null)
- return false;
-
+ foreach (Type itype in TypeManager.GetInterfaces (ptype)) {
if (!CheckConstraint (ec, ptype, aexpr, itype)) {
Report.Error (309, loc, "The type `{0}' must be " +
"convertible to `{1}' in order to " +
get { return false; }
}
- public override TypeExpr[] GetInterfaces ()
- {
- TypeExpr[] ifaces = TypeManager.GetInterfaces (gt);
- return ifaces;
- }
-
public override bool Equals (object obj)
{
ConstructedType cobj = obj as ConstructedType;