use of dyvilx.tools.compiler.ast.type.IType in project Dyvil by Dyvil.
the class WildcardType method getConcreteType.
@Override
public IType getConcreteType(ITypeContext context) {
if (context == ITypeContext.COVARIANT) {
return this.asParameterType();
}
final IType concretetype = this.type.getConcreteType(context);
if (concretetype == this.type) {
return this;
}
if (concretetype.typeTag() == WILDCARD_TYPE) {
return concretetype;
}
final WildcardType copy = new WildcardType(this.position, this.variance);
copy.type = concretetype;
return copy;
}
use of dyvilx.tools.compiler.ast.type.IType in project Dyvil by Dyvil.
the class WildcardType method withAnnotation.
@Override
public IType withAnnotation(Annotation annotation) {
final IType a = this.type.withAnnotation(annotation);
if (a == null) {
return null;
}
this.type = a;
return this;
}
use of dyvilx.tools.compiler.ast.type.IType in project Dyvil by Dyvil.
the class ClassGenericType method argumentsMatch.
protected boolean argumentsMatch(IType type) {
final int count = Math.min(this.arguments.size(), this.getTheClass().typeArity());
final TypeParameterList classTypeParams = this.getTheClass().getTypeParameters();
for (int i = 0; i < count; i++) {
final ITypeParameter typeVar = classTypeParams.get(i);
final IType thisArgument = this.arguments.get(i);
final IType thatArgument = type.resolveType(typeVar);
if (thatArgument != null && !Variance.checkCompatible(typeVar.getVariance(), thisArgument, thatArgument)) {
return false;
}
}
return true;
}
use of dyvilx.tools.compiler.ast.type.IType in project Dyvil by Dyvil.
the class GenericType method getConcreteTypes.
public static TypeList getConcreteTypes(TypeList types, ITypeContext context) {
TypeList newTypes = null;
for (int i = 0, count = types.size(); i < count; i++) {
final IType original = types.get(i);
final IType concrete = original.getConcreteType(context);
if (newTypes != null) {
newTypes.set(i, concrete);
} else if (concrete != original) {
// If there is a single mismatch, create the array and copy previous elements
newTypes = types.copy();
newTypes.set(i, concrete);
}
}
return newTypes != null ? newTypes : types;
}
use of dyvilx.tools.compiler.ast.type.IType in project Dyvil by Dyvil.
the class InfixTypeChain method resolveType.
@Override
public IType resolveType(MarkerList markers, IContext context) {
this.resolveOperators(markers, context);
final IType treeify = this.treeify(markers);
return treeify.resolveType(markers, context);
}
Aggregations