use of dyvilx.tools.compiler.util.Markers 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);
}
use of dyvilx.tools.compiler.util.Markers in project Dyvil by Dyvil.
the class IDataMember method checkAssign.
default IValue checkAssign(MarkerList markers, IContext context, SourcePosition position, IValue receiver, IValue newValue) {
if (this.hasModifier(Modifiers.FINAL) && !context.isConstructor()) {
markers.add(Markers.semanticError(position, this.getKind().getName() + ".assign.final", this.getName()));
}
final IType type = this.getType();
final ITypeContext typeContext = receiver == null ? ITypeContext.NULL : receiver.getType();
final TypeChecker.MarkerSupplier markerSupplier = (errorPosition, expected, actual) -> {
final String kindName = this.getKind().getName();
final Marker marker = Markers.semanticError(errorPosition, kindName + ".assign.type", this.getName());
marker.addInfo(Markers.getSemantic(kindName + ".type", expected));
marker.addInfo(Markers.getSemantic("value.type", actual));
return marker;
};
return TypeChecker.convertValue(newValue, type, typeContext, markers, context, markerSupplier);
}
Aggregations