use of com.redhat.ceylon.model.typechecker.model.Type in project ceylon-compiler by ceylon.
the class UnknownTypeCollector method collectUnknownTypesResolved.
private void collectUnknownTypesResolved(Type type, Map<Declaration, Declaration> visited) {
if (type != null) {
collectUnknownTypes(type, visited);
List<Type> typeArguments = type.getTypeArgumentList();
// cheaper c-for than foreach
for (int i = 0, l = typeArguments.size(); i < l; i++) {
Type tl = typeArguments.get(i);
collectUnknownTypesResolved(tl, visited);
}
}
}
use of com.redhat.ceylon.model.typechecker.model.Type in project ceylon-compiler by ceylon.
the class CeylonEnter method resetClassSymbol.
/**
* This resets a ClassSymbol recursively, for bootstrap
*/
private void resetClassSymbol(ClassSymbol classSymbol) {
// look for inner classes
if (classSymbol.members_field != null) {
for (Symbol member : classSymbol.getEnclosedElements()) {
if (member instanceof ClassSymbol) {
resetClassSymbol((ClassSymbol) member);
}
}
}
// reset its type, we need to keep it
com.sun.tools.javac.code.Type.ClassType classType = (ClassType) classSymbol.type;
classType.all_interfaces_field = null;
classType.interfaces_field = null;
classType.supertype_field = null;
classType.typarams_field = null;
// reset its members and completer
classSymbol.members_field = null;
classSymbol.completer = null;
classSymbol.attributes_field = List.nil();
}
use of com.redhat.ceylon.model.typechecker.model.Type in project ceylon-compiler by ceylon.
the class TypeParserTests method assertTypeWithParameters.
private void assertTypeWithParameters(Type type) {
Assert.assertNotNull(type);
TypeDeclaration declaration = type.getDeclaration();
Assert.assertNotNull(declaration);
Assert.assertTrue(declaration instanceof Class);
Assert.assertEquals("t2", declaration.getName());
List<Type> tal = type.getTypeArgumentList();
Assert.assertEquals(2, tal.size());
Assert.assertEquals("b", tal.get(0).getDeclaration().getName());
Assert.assertTrue(tal.get(0).getDeclaration() instanceof Class);
Assert.assertEquals("c", tal.get(1).getDeclaration().getName());
Assert.assertTrue(tal.get(1).getDeclaration() instanceof Class);
}
use of com.redhat.ceylon.model.typechecker.model.Type in project ceylon-compiler by ceylon.
the class TypeParserTests method testCallableAbbrev.
@Test
public void testCallableAbbrev() {
Type type = new TypeParser(MockLoader.instance).decodeType("a(b)", null, mockDefaultModule, mockPkgUnit);
Assert.assertNotNull(type);
TypeDeclaration declaration = type.getDeclaration();
Assert.assertNotNull(declaration);
Assert.assertTrue(declaration instanceof Interface);
Assert.assertEquals("ceylon.language::Callable", declaration.getQualifiedNameString());
Assert.assertEquals("a(b)", type.asString());
Assert.assertNull(type.getQualifyingType());
type = new TypeParser(MockLoader.instance).decodeType("a(b,pkg::u*)", null, mockPkgModule, mockPkgUnit);
Assert.assertNotNull(type);
declaration = type.getDeclaration();
Assert.assertNotNull(declaration);
Assert.assertTrue(declaration instanceof Interface);
Assert.assertEquals("ceylon.language::Callable", declaration.getQualifiedNameString());
Assert.assertEquals("ceylon.language::Callable<a,ceylon.language::Tuple<b|pkg::u,b,ceylon.language::Sequential<pkg::u>>>", printType(type));
Assert.assertNull(type.getQualifyingType());
type = new TypeParser(MockLoader.instance).decodeType("a(b=,pkg::u*)", null, mockPkgModule, mockPkgUnit);
Assert.assertNotNull(type);
declaration = type.getDeclaration();
Assert.assertNotNull(declaration);
Assert.assertTrue(declaration instanceof Interface);
Assert.assertEquals("ceylon.language::Callable", declaration.getQualifiedNameString());
Assert.assertEquals("ceylon.language::Callable<a,ceylon.language::Empty|ceylon.language::Tuple<b|pkg::u,b,ceylon.language::Sequential<pkg::u>>>", printType(type));
Assert.assertNull(type.getQualifyingType());
}
use of com.redhat.ceylon.model.typechecker.model.Type in project ceylon-compiler by ceylon.
the class TypeParserTests method testParamsVariance2.
@Test
public void testParamsVariance2() {
Type type = new TypeParser(MockLoader.instance).decodeType("t2<b,out c>", null, mockDefaultModule, mockPkgUnit);
assertTypeWithParameters(type);
Map<TypeParameter, SiteVariance> varianceOverrides = type.getVarianceOverrides();
Assert.assertNotNull(varianceOverrides);
Assert.assertEquals(1, varianceOverrides.size());
List<TypeParameter> tps = type.getDeclaration().getTypeParameters();
Assert.assertEquals(null, varianceOverrides.get(tps.get(0)));
Assert.assertEquals(SiteVariance.OUT, varianceOverrides.get(tps.get(1)));
}
Aggregations