Search in sources :

Example 1 with ITypeParametric

use of dyvilx.tools.compiler.ast.generic.ITypeParametric in project Dyvil by Dyvil.

the class NamedGenericType method checkCount.

private IType checkCount(MarkerList markers, ITypeParametric generic, String kind, IType type) {
    final int genericArity = generic.typeArity();
    if (genericArity <= 0) {
        markers.add(Markers.semanticError(this.position, "type.generic." + kind + ".not_generic", type));
        return type.atPosition(this.position);
    }
    if (genericArity != this.arguments.size()) {
        final Marker marker = Markers.semanticError(this.position, "type.generic." + kind + ".count_mismatch", type);
        marker.addInfo(Markers.getSemantic("type.generic.argument_count", this.arguments.size()));
        marker.addInfo(Markers.getSemantic("type.generic.parameter_count", genericArity));
        markers.add(marker);
    }
    return type.getConcreteType(typeParameter -> this.arguments.get(typeParameter.getIndex())).atPosition(this.position);
}
Also used : DataOutput(java.io.DataOutput) IContext(dyvilx.tools.compiler.ast.context.IContext) Package(dyvilx.tools.compiler.ast.structure.Package) Name(dyvil.lang.Name) ResolvedTypeVarType(dyvilx.tools.compiler.ast.type.typevar.ResolvedTypeVarType) IType(dyvilx.tools.compiler.ast.type.IType) IOException(java.io.IOException) Types(dyvilx.tools.compiler.ast.type.builtin.Types) PackageType(dyvilx.tools.compiler.ast.type.raw.PackageType) Marker(dyvilx.tools.parsing.marker.Marker) ITypeAlias(dyvilx.tools.compiler.ast.type.alias.ITypeAlias) ITypeParametric(dyvilx.tools.compiler.ast.generic.ITypeParametric) Markers(dyvilx.tools.compiler.util.Markers) SourcePosition(dyvil.source.position.SourcePosition) ITypeParameter(dyvilx.tools.compiler.ast.generic.ITypeParameter) TypeList(dyvilx.tools.compiler.ast.type.TypeList) MarkerList(dyvilx.tools.parsing.marker.MarkerList) DataInput(java.io.DataInput) MatchList(dyvilx.tools.compiler.ast.method.MatchList) IClass(dyvilx.tools.compiler.ast.classes.IClass) IUnresolvedType(dyvilx.tools.compiler.ast.type.raw.IUnresolvedType) Marker(dyvilx.tools.parsing.marker.Marker)

Aggregations

Name (dyvil.lang.Name)1 SourcePosition (dyvil.source.position.SourcePosition)1 IClass (dyvilx.tools.compiler.ast.classes.IClass)1 IContext (dyvilx.tools.compiler.ast.context.IContext)1 ITypeParameter (dyvilx.tools.compiler.ast.generic.ITypeParameter)1 ITypeParametric (dyvilx.tools.compiler.ast.generic.ITypeParametric)1 MatchList (dyvilx.tools.compiler.ast.method.MatchList)1 Package (dyvilx.tools.compiler.ast.structure.Package)1 IType (dyvilx.tools.compiler.ast.type.IType)1 TypeList (dyvilx.tools.compiler.ast.type.TypeList)1 ITypeAlias (dyvilx.tools.compiler.ast.type.alias.ITypeAlias)1 Types (dyvilx.tools.compiler.ast.type.builtin.Types)1 IUnresolvedType (dyvilx.tools.compiler.ast.type.raw.IUnresolvedType)1 PackageType (dyvilx.tools.compiler.ast.type.raw.PackageType)1 ResolvedTypeVarType (dyvilx.tools.compiler.ast.type.typevar.ResolvedTypeVarType)1 Markers (dyvilx.tools.compiler.util.Markers)1 Marker (dyvilx.tools.parsing.marker.Marker)1 MarkerList (dyvilx.tools.parsing.marker.MarkerList)1 DataInput (java.io.DataInput)1 DataOutput (java.io.DataOutput)1