Search in sources :

Example 11 with LazyType

use of org.eclipse.ceylon.model.typechecker.model.LazyType in project ceylon by eclipse.

the class DeclarationVisitor method visit.

public void visit(Tree.IntersectionType that) {
    super.visit(that);
    if (inExtends) {
        final List<Tree.StaticType> sts = that.getStaticTypes();
        Type t = new LazyType(unit) {

            @Override
            public TypeDeclaration initDeclaration() {
                List<Type> types = new ArrayList<Type>(sts.size());
                for (Tree.StaticType st : sts) {
                    Type t = st.getTypeModel();
                    if (t != null) {
                        types.add(t);
                    }
                }
                IntersectionType it = new IntersectionType(unit);
                it.setSatisfiedTypes(types);
                return it;
            }

            @Override
            public Map<TypeParameter, Type> initTypeArguments() {
                return emptyMap();
            }
        };
        that.setTypeModel(t);
    }
}
Also used : IntersectionType(org.eclipse.ceylon.model.typechecker.model.IntersectionType) LazyType(org.eclipse.ceylon.model.typechecker.model.LazyType) UnionType(org.eclipse.ceylon.model.typechecker.model.UnionType) Type(org.eclipse.ceylon.model.typechecker.model.Type) UnknownType(org.eclipse.ceylon.model.typechecker.model.UnknownType) TypeVisitor.getTupleType(org.eclipse.ceylon.compiler.typechecker.analyzer.TypeVisitor.getTupleType) TypeParameter(org.eclipse.ceylon.model.typechecker.model.TypeParameter) IntersectionType(org.eclipse.ceylon.model.typechecker.model.IntersectionType) LazyType(org.eclipse.ceylon.model.typechecker.model.LazyType) ArrayList(java.util.ArrayList) CustomTree(org.eclipse.ceylon.compiler.typechecker.tree.CustomTree) Tree(org.eclipse.ceylon.compiler.typechecker.tree.Tree)

Example 12 with LazyType

use of org.eclipse.ceylon.model.typechecker.model.LazyType in project ceylon by eclipse.

the class DeclarationVisitor method visit.

public void visit(Tree.EntryType that) {
    super.visit(that);
    if (inExtends) {
        final Tree.StaticType keyType = that.getKeyType();
        final Tree.StaticType valueType = that.getValueType();
        Type t = new LazyType(unit) {

            @Override
            public boolean isUnknown() {
                return false;
            }

            @Override
            public TypeDeclaration initDeclaration() {
                return unit.getEntryDeclaration();
            }

            @Override
            public Map<TypeParameter, Type> initTypeArguments() {
                HashMap<TypeParameter, Type> map = new HashMap<TypeParameter, Type>();
                List<TypeParameter> itps = unit.getEntryDeclaration().getTypeParameters();
                map.put(itps.get(0), keyType.getTypeModel());
                map.put(itps.get(1), valueType.getTypeModel());
                return map;
            }
        };
        that.setTypeModel(t);
    }
}
Also used : IntersectionType(org.eclipse.ceylon.model.typechecker.model.IntersectionType) LazyType(org.eclipse.ceylon.model.typechecker.model.LazyType) UnionType(org.eclipse.ceylon.model.typechecker.model.UnionType) Type(org.eclipse.ceylon.model.typechecker.model.Type) UnknownType(org.eclipse.ceylon.model.typechecker.model.UnknownType) TypeVisitor.getTupleType(org.eclipse.ceylon.compiler.typechecker.analyzer.TypeVisitor.getTupleType) TypeParameter(org.eclipse.ceylon.model.typechecker.model.TypeParameter) HashMap(java.util.HashMap) LazyType(org.eclipse.ceylon.model.typechecker.model.LazyType) CustomTree(org.eclipse.ceylon.compiler.typechecker.tree.CustomTree) Tree(org.eclipse.ceylon.compiler.typechecker.tree.Tree)

Example 13 with LazyType

use of org.eclipse.ceylon.model.typechecker.model.LazyType in project ceylon by eclipse.

the class DeclarationVisitor method visit.

public void visit(Tree.TupleType that) {
    super.visit(that);
    if (inExtends) {
        final List<Tree.Type> ets = that.getElementTypes();
        Type t = new LazyType(unit) {

            private Type tupleType() {
                return getTupleType(ets, unit);
            }

            @Override
            public TypeDeclaration initDeclaration() {
                return tupleType().getDeclaration();
            }

            @Override
            public Map<TypeParameter, Type> initTypeArguments() {
                return tupleType().getTypeArguments();
            }
        };
        that.setTypeModel(t);
    }
}
Also used : IntersectionType(org.eclipse.ceylon.model.typechecker.model.IntersectionType) LazyType(org.eclipse.ceylon.model.typechecker.model.LazyType) UnionType(org.eclipse.ceylon.model.typechecker.model.UnionType) Type(org.eclipse.ceylon.model.typechecker.model.Type) UnknownType(org.eclipse.ceylon.model.typechecker.model.UnknownType) TypeVisitor.getTupleType(org.eclipse.ceylon.compiler.typechecker.analyzer.TypeVisitor.getTupleType) TypeParameter(org.eclipse.ceylon.model.typechecker.model.TypeParameter) LazyType(org.eclipse.ceylon.model.typechecker.model.LazyType)

Aggregations

IntersectionType (org.eclipse.ceylon.model.typechecker.model.IntersectionType)13 LazyType (org.eclipse.ceylon.model.typechecker.model.LazyType)13 Type (org.eclipse.ceylon.model.typechecker.model.Type)13 TypeVisitor.getTupleType (org.eclipse.ceylon.compiler.typechecker.analyzer.TypeVisitor.getTupleType)12 TypeParameter (org.eclipse.ceylon.model.typechecker.model.TypeParameter)12 UnionType (org.eclipse.ceylon.model.typechecker.model.UnionType)12 UnknownType (org.eclipse.ceylon.model.typechecker.model.UnknownType)12 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)10 CustomTree (org.eclipse.ceylon.compiler.typechecker.tree.CustomTree)9 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)4 AnalyzerUtil.getPackageTypeDeclaration (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getPackageTypeDeclaration)3 AnalyzerUtil.getTypeDeclaration (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getTypeDeclaration)3 Collections.emptyMap (java.util.Collections.emptyMap)2 Map (java.util.Map)2 ClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)2 ConditionScope (org.eclipse.ceylon.model.typechecker.model.ConditionScope)2 ModelUtil.getContainingClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ModelUtil.getContainingClassOrInterface)2 ModelUtil.getRealScope (org.eclipse.ceylon.model.typechecker.model.ModelUtil.getRealScope)2