Search in sources :

Example 1 with UnknownType

use of com.redhat.ceylon.model.typechecker.model.UnknownType in project ceylon-compiler by ceylon.

the class UnknownTypeCollector method collectUnknownTypes.

private void collectUnknownTypes(Type type, Map<Declaration, Declaration> visited) {
    if (type != null) {
        type = type.resolveAliases();
        if (type.isUnknown()) {
            UnknownType ut = (UnknownType) type.getDeclaration();
            ut.reportErrors();
            // don't report it twice
            ut.setErrorReporter(null);
        } else if (type.isUnion()) {
            for (Type t : type.getCaseTypes()) {
                collectUnknownTypesResolved(t, visited);
            }
        } else if (type.isIntersection()) {
            for (Type t : type.getSatisfiedTypes()) {
                collectUnknownTypesResolved(t, visited);
            }
        } else if (type.isUnknown() || type.isTypeParameter()) {
        // do nothing
        } else {
            TypeDeclaration declaration = type.getDeclaration();
            if (visited.put(declaration, declaration) != null)
                return;
            if (type.isClassOrInterface()) {
                // these are not resolved
                if (type.getExtendedType() != null)
                    collectUnknownTypes(type.getExtendedType(), visited);
                for (Type t : type.getSatisfiedTypes()) collectUnknownTypes(t, visited);
            }
        }
    }
}
Also used : UnknownType(com.redhat.ceylon.model.typechecker.model.UnknownType) UnknownType(com.redhat.ceylon.model.typechecker.model.UnknownType) Type(com.redhat.ceylon.model.typechecker.model.Type) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Aggregations

Type (com.redhat.ceylon.model.typechecker.model.Type)1 TypeDeclaration (com.redhat.ceylon.model.typechecker.model.TypeDeclaration)1 UnknownType (com.redhat.ceylon.model.typechecker.model.UnknownType)1