use of abs.frontend.typechecker.DataTypeType in project abstools by abstools.
the class TypingTest method functionTypeArgs.
@Test
public void functionTypeArgs() {
Model m = assertParseOkStdLib(" def Maybe<A> f<A>() = None ;");
ParametricFunctionDecl d = getLastParametricFunctionDecl(m);
DataTypeType t = (DataTypeType) d.getTypeUse().getType();
TypeParameter typeArg = (TypeParameter) t.getTypeArg(0);
assertEquals(typeArg.getDecl(), d.getTypeParameter(0));
}
use of abs.frontend.typechecker.DataTypeType in project abstools by abstools.
the class TypeExtensionHelper method annotateType.
public void annotateType(Type t, ASTNode<?> originatingNode, ASTNode<?> typeNode) {
if (t.isDataType()) {
DataTypeType dt = (DataTypeType) t;
if (dt.hasTypeArgs()) {
ParametricDataTypeUse pu = null;
// typeNode maybe a type synonym
if (typeNode instanceof ParametricDataTypeUse)
pu = (ParametricDataTypeUse) typeNode;
int i = 0;
for (Type ta : dt.getTypeArgs()) {
ASTNode<?> childTypeNode = null;
if (pu != null)
childTypeNode = pu.getParam(i);
annotateType(ta, originatingNode, childTypeNode);
i++;
}
}
}
if (t.isReferenceType() || t.isNullType()) {
for (TypeSystemExtension tse : obs) {
tse.annotateType(t, originatingNode, typeNode);
}
}
}
Aggregations