Search in sources :

Example 6 with TypeParameter

use of org.abs_models.frontend.typechecker.TypeParameter in project abstools by abstools.

the class TypingTest method functionTypeArgs.

@Test
public void functionTypeArgs() {
    Model m = assertParse(" 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));
}
Also used : ParametricFunctionDecl(org.abs_models.frontend.ast.ParametricFunctionDecl) TypeParameter(org.abs_models.frontend.typechecker.TypeParameter) Model(org.abs_models.frontend.ast.Model) DataTypeType(org.abs_models.frontend.typechecker.DataTypeType) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 7 with TypeParameter

use of org.abs_models.frontend.typechecker.TypeParameter 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);
}
Also used : TypeParameterDecl(org.abs_models.frontend.ast.TypeParameterDecl) ParametricFunctionDecl(org.abs_models.frontend.ast.ParametricFunctionDecl) TypeParameter(org.abs_models.frontend.typechecker.TypeParameter) Model(org.abs_models.frontend.ast.Model) ExpFunctionDef(org.abs_models.frontend.ast.ExpFunctionDef) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Aggregations

TypeParameter (org.abs_models.frontend.typechecker.TypeParameter)7 DataTypeType (org.abs_models.frontend.typechecker.DataTypeType)5 BoundedType (org.abs_models.frontend.typechecker.BoundedType)4 Type (org.abs_models.frontend.typechecker.Type)4 FrontendTest (org.abs_models.frontend.FrontendTest)3 Model (org.abs_models.frontend.ast.Model)3 ParametricFunctionDecl (org.abs_models.frontend.ast.ParametricFunctionDecl)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 ExpFunctionDef (org.abs_models.frontend.ast.ExpFunctionDef)2 TypeParameterDecl (org.abs_models.frontend.ast.TypeParameterDecl)2 ABSString (org.abs_models.backend.java.lib.types.ABSString)1 InterfaceType (org.abs_models.frontend.typechecker.InterfaceType)1 UnionType (org.abs_models.frontend.typechecker.UnionType)1