use of org.abs_models.frontend.ast.TypeParameterDecl in project abstools by abstools.
the class TypingTest method functionTypeArgs5.
@Test
public void functionTypeArgs5() {
Model m = assertParse("def B nth<B>(List<B> list, Int n) = nth(tail(list), n-1) ; ");
ParametricFunctionDecl d = getLastParametricFunctionDecl(m);
TypeParameterDecl typeParameter = d.getTypeParameter(0);
TypeParameter type = (TypeParameter) ((ExpFunctionDef) d.getFunctionDef()).getRhs().getType();
assertEquals(typeParameter.getName(), type.getDecl().getName());
}
use of org.abs_models.frontend.ast.TypeParameterDecl in project abstools by abstools.
the class JavaGeneratorHelper method generateTypeParameters.
public static void generateTypeParameters(PrintStream stream, Decl dtd, boolean plusExtends) {
List<TypeParameterDecl> typeParams = null;
if (dtd instanceof HasTypeParameters) {
typeParams = ((HasTypeParameters) dtd).getTypeParameters();
} else
return;
if (typeParams.getNumChild() > 0) {
stream.print("<");
boolean isFirst = true;
for (TypeParameterDecl d : typeParams) {
if (isFirst)
isFirst = false;
else
stream.print(",");
stream.print(d.getName());
if (plusExtends)
stream.print(" extends " + ABSValue.class.getName());
}
stream.print(">");
}
}
use of org.abs_models.frontend.ast.TypeParameterDecl in project abstools by abstools.
the class TypingTest method functionTypeArgs3.
@Test
public void functionTypeArgs3() {
Model m = assertParse(" def A f<A>(Maybe<A> o) = case o { Just(a) => a; } ;");
ParametricFunctionDecl d = getLastParametricFunctionDecl(m);
TypeParameterDecl typeParameter = d.getTypeParameter(0);
TypeParameter type = (TypeParameter) ((ExpFunctionDef) d.getFunctionDef()).getRhs().getType();
TypeParameterDecl decl = type.getDecl();
assertEquals(typeParameter, decl);
}
Aggregations