use of abs.frontend.typechecker.UnionType in project abstools by abstools.
the class TypingTest method testThisTyping.
@Test
public void testThisTyping() {
Model m = assertParseOk("class C implements I { I m() { return this; } } interface I { }");
ClassDecl d = (ClassDecl) m.lookupModule("UnitTest").getDecl(0);
ReturnStmt s = (ReturnStmt) d.getMethod(0).getBlock().getStmt(0);
assertEquals(m.lookupModule("UnitTest").getDecl(1), ((UnionType) s.getRetExp().getType()).getType(0).getDecl());
}
use of abs.frontend.typechecker.UnionType in project abstools by abstools.
the class TypeHierarchyContentProvider method getElements.
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof Type) {
Type type = (Type) inputElement;
if (type.getDecl() != null) {
return new Object[] { type.getDecl() };
}
if (type instanceof UnionType) {
UnionType unionType = (UnionType) type;
java.util.List<Object> result = new ArrayList<Object>();
for (InterfaceType t : unionType.getTypes()) {
for (Object e : getElements(t)) {
result.add(e);
}
}
return result.toArray();
}
}
return nothing;
}
Aggregations