static TypeInfo bindGenericParameters(Library typeSystem, GenericParameterBindings genericsScope, TypeInfo typeInfo) { if (genericsScope.hasBinding(typeInfo)) { return(genericsScope.getBindingValue(typeInfo)); } else if (typeInfo.IsArray) { return(bindGenericParameters(typeSystem, genericsScope, typeInfo.ElementType).ArrayType); } else if (typeInfo.TypeKind == TypeKind.UpperBoundedWildcard) { return(bindGenericParameters(typeSystem, genericsScope, typeInfo.WildcardBound).UpperBoundedWildcard); } else if (typeInfo.TypeKind == TypeKind.LowerBoundedWildcard) { return(bindGenericParameters(typeSystem, genericsScope, typeInfo.WildcardBound).LowerBoundedWildcard); } else if (!typeInfo.IsClosed && typeInfo.GenericArguments.any()) { return(typeSystem.getGenericType(typeInfo, bindGenericParameters(typeSystem, genericsScope, typeInfo.GenericArguments), genericsScope)); } else if (typeInfo.IsGenericParameter && typeInfo.GenericParameterBounds.any()) { var param = new GenericParameterType(typeSystem, typeInfo.FullName, typeInfo); genericsScope.declareBinding(typeInfo, param); foreach (var t in typeInfo.GenericParameterBounds) { param.genericParameterBounds.add(bindGenericParameters(typeSystem, genericsScope, t)); } return(param); } return(typeInfo); }
static void declareGenericTypeBindings(GenericParameterBindings genericsScope, Iterable <TypeInfo> keys, Iterable <TypeInfo> values) { if (keys.count() != values.count()) { throw new IllegalStateException(); } var it1 = keys.iterator(); var it2 = values.iterator(); while (it1.hasNext()) { var t1 = it1.next(); var t2 = it2.next(); if (t1.IsGenericParameter) { genericsScope.declareBinding(t1, t2); } } }
ConstructedGenericType(Library typeSystem, TypeInfo declaringType, TypeInfo genericTypeDefinition, Iterable <TypeInfo> genericArguments, GenericParameterBindings genericsScope) : super(typeSystem, genericTypeDefinition.FullName)
GenericParameterBindings(GenericParameterBindings next) { this.next = next; this.bindings = new HashMap <TypeInfo, TypeInfo>(); }
static Iterable <TypeInfo> bindGenericParameters(Library typeSystem, GenericParameterBindings genericsScope, Iterable <TypeInfo> types) { return(types.select(p => bindGenericParameters(typeSystem, genericsScope, p)).toList()); }
ConstructedGenericMethod(Library typeSystem, TypeInfo declaringType, MethodInfo genericMethodDefinition, Iterable <TypeInfo> genericArguments, GenericParameterBindings genericsScope) : super(declaringType, genericMethodDefinition.Name)