Search in sources :

Example 1 with IType

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;
}
Also used : IType(dyvilx.tools.compiler.ast.type.IType)

Example 2 with IType

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;
}
Also used : IType(dyvilx.tools.compiler.ast.type.IType)

Example 3 with IType

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;
}
Also used : TypeParameterList(dyvilx.tools.compiler.ast.generic.TypeParameterList) ITypeParameter(dyvilx.tools.compiler.ast.generic.ITypeParameter) IType(dyvilx.tools.compiler.ast.type.IType)

Example 4 with IType

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;
}
Also used : TypeList(dyvilx.tools.compiler.ast.type.TypeList) IType(dyvilx.tools.compiler.ast.type.IType)

Example 5 with IType

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);
}
Also used : IType(dyvilx.tools.compiler.ast.type.IType)

Aggregations

IType (dyvilx.tools.compiler.ast.type.IType)159 IClass (dyvilx.tools.compiler.ast.classes.IClass)26 Marker (dyvilx.tools.parsing.marker.Marker)23 IValue (dyvilx.tools.compiler.ast.expression.IValue)21 TypeParameterList (dyvilx.tools.compiler.ast.generic.TypeParameterList)13 ParameterList (dyvilx.tools.compiler.ast.parameter.ParameterList)11 IParameter (dyvilx.tools.compiler.ast.parameter.IParameter)10 SourcePosition (dyvil.source.position.SourcePosition)9 Annotation (dyvilx.tools.compiler.ast.attribute.annotation.Annotation)9 ITypeParameter (dyvilx.tools.compiler.ast.generic.ITypeParameter)9 ArgumentList (dyvilx.tools.compiler.ast.parameter.ArgumentList)9 TypeList (dyvilx.tools.compiler.ast.type.TypeList)7 AttributeList (dyvilx.tools.compiler.ast.attribute.AttributeList)6 FieldAccess (dyvilx.tools.compiler.ast.expression.access.FieldAccess)6 IVariable (dyvilx.tools.compiler.ast.field.IVariable)6 ArrayType (dyvilx.tools.compiler.ast.type.compound.ArrayType)6 MethodWriter (dyvilx.tools.compiler.backend.MethodWriter)6 CodeMethod (dyvilx.tools.compiler.ast.method.CodeMethod)5 CodeParameter (dyvilx.tools.compiler.ast.parameter.CodeParameter)5 Name (dyvil.lang.Name)4