Package com.redhat.ceylon.compiler.typechecker.model

Examples of com.redhat.ceylon.compiler.typechecker.model.TypeDeclaration


    @Override
    public void visit(Tree.SatisfiedTypes that) {
        inExtends = true;
        super.visit(that);
        inExtends = false;
        TypeDeclaration td = (TypeDeclaration) that.getScope();
        if (td.isAlias()) {
            return;
        }
        for (Tree.StaticType t: that.getTypes()) {
            if (t!=null) {
                ProducedType type = t.getTypeModel();
                if (type!=null) {
                    td.getSatisfiedTypes().add(type);
                }
            }
        }
    }
View Full Code Here


        }
        else if (that.getInvocationExpression()==null) {
            that.addError("missing instantiation arguments");
        }
        else {
            TypeDeclaration td = (TypeDeclaration) that.getScope();
            ProducedType type = that.getType().getTypeModel();
            if (type!=null) {
                td.setExtendedType(type);
            }
            if (that.getMainToken().getType()==SPECIFY) {
                that.addError("incorrect syntax: aliased class must be specified using =>", 1050);
            }
        }
View Full Code Here

        inExtends = false;
        if (that.getType()==null) {
            that.addError("missing aliased type");
        }
        else if (!(that instanceof Tree.DefaultTypeArgument)) {
            TypeDeclaration td = (TypeDeclaration) that.getScope();
            ProducedType type = that.getType().getTypeModel();
            if (type!=null) {
                td.setExtendedType(type);
            }
            if (that.getMainToken().getType()==SPECIFY) {
                that.addError("incorrect syntax: aliased type must be specified using =>", 1050);
            }
        }
View Full Code Here

        Tree.ImportMemberOrTypeList imtl = member.getImportMemberOrTypeList();
        if (imtl!=null) {
            if (d instanceof TypeDeclaration) {
                Set<String> names = new HashSet<String>();
                ImportList til = imtl.getImportList();
                TypeDeclaration td = (TypeDeclaration) d;
                til.setImportedScope(td);
                for (Tree.ImportMemberOrType submember: imtl.getImportMemberOrTypes()) {
                    names.add(importMember(submember, td, til));
                }
                if (imtl.getImportWildcard()!=null) {
View Full Code Here

    }
   
    @Override
    public void visit(Tree.BaseType that) {
        super.visit(that);
        TypeDeclaration type = getTypeDeclaration(that.getScope(),
                name(that.getIdentifier()), null, false, that.getUnit());
        String name = name(that.getIdentifier());
        if (type==null) {
            that.addError("type declaration does not exist: '" + name + "'", 102);
            unit.getUnresolvedReferences().add(that.getIdentifier());
View Full Code Here

                    that.getTypeArgumentList()!=null &&
                    isTypeUnknown(pt) && !pt.isUnknown()) {
                that.getTypeArgumentList()
                        .addError("qualifying type does not fully-specify type arguments");
            }
            TypeDeclaration d = pt.getDeclaration();
            String name = name(that.getIdentifier());
            TypeDeclaration type = getTypeMember(d, name, null, false, unit);
            if (type==null) {
                if (d.isMemberAmbiguous(name, unit, null, false)) {
                    that.addError("member type declaration is ambiguous: '" +
                            name + "' for type '" + d.getName() + "'");
                }
View Full Code Here

                    }
                    else {
                        ct.addError("not a class: '" +
                                type.getDeclaration().getName(unit) + "'");
                    }
                    TypeDeclaration etd = ct.getDeclarationModel();
                    if (etd==td) {
                        //TODO: handle indirect circularities!
                        ct.addError("directly aliases itself: '" + td.getName() + "'");
                        return;
                    }
View Full Code Here

    }
   
    @Override
    public void visit(Tree.ExtendedType that) {
        super.visit(that);
        TypeDeclaration td = (TypeDeclaration) that.getScope();
        if (td.isAlias()) {
            return;
        }
        Tree.SimpleType et = that.getType();
        if (et==null) {
//            that.addError("malformed extended type");
        }
        else {
            /*if (et instanceof Tree.QualifiedType) {
                Tree.QualifiedType st = (Tree.QualifiedType) et;
                ProducedType pt = st.getOuterType().getTypeModel();
                if (pt!=null) {
                    TypeDeclaration superclass = (TypeDeclaration) getMemberDeclaration(pt.getDeclaration(), st.getIdentifier(), context);
                    if (superclass==null) {
                        that.addError("member type declaration not found: " +
                                st.getIdentifier().getText());
                    }
                    else {
                        visitExtendedType(st, pt, superclass);
                    }
                }
            }*/
            ProducedType type = et.getTypeModel();
            if (type!=null) {
                TypeDeclaration etd = et.getDeclarationModel();
                if (etd!=null) {
                    if (etd==td) {
                        //TODO: handle indirect circularities!
                        et.addError("directly extends itself: '" + td.getName() + "'");
                    }
View Full Code Here

    }
   
    @Override
    public void visit(Tree.SatisfiedTypes that) {
        super.visit(that);
        TypeDeclaration td = (TypeDeclaration) that.getScope();
        if (td.isAlias()) {
            return;
        }
        List<ProducedType> list = new ArrayList<ProducedType>(that.getTypes().size());
        if ( that.getTypes().isEmpty() ) {
            that.addError("missing types in satisfies");
        }
        boolean foundTypeParam = false;
        boolean foundClass = false;
        boolean foundInterface = false;
        for (Tree.StaticType st: that.getTypes()) {
            ProducedType type = st.getTypeModel();
            if (type!=null) {
                TypeDeclaration std = type.getDeclaration();
                if (std!=null && !(std instanceof UnknownType)) {
                    if (std==td) {
                        //TODO: handle indirect circularities!
                        st.addError("directly extends itself: '" + td.getName() + "'");
                        continue;
                    }
                    if (std instanceof TypeAlias) {
                        st.addError("satisfies a type alias: '" +
                                type.getDeclaration().getName(unit) + "'");
                        continue;
                    }
                    if (td instanceof TypeParameter) {
                        if (foundTypeParam) {
                            st.addUnsupportedError("type parameter upper bounds are not yet supported in combination with other bounds");
                        }
                        else if (std instanceof TypeParameter) {
                            if (foundClass||foundInterface) {
                                st.addUnsupportedError("type parameter upper bounds are not yet supported in combination with other bounds");
                            }
                            foundTypeParam = true;
                        }
                        else if (std instanceof Class) {
                            if (foundClass) {
                                st.addUnsupportedError("multiple class upper bounds are not yet supported");
                            }
                            foundClass = true;
                        }
                        else if (std instanceof Interface) {
                            foundInterface = true;
                        }
                        else {
                            st.addError("upper bound must be a class, interface, or type parameter");
                            continue;
                        }
                    }
                    else {
                        if (std instanceof TypeParameter) {
                            st.addError("directly satisfies type parameter: '" + std.getName(unit) + "'");
                            continue;
                        }
                        else if (std instanceof Class) {
                            st.addError("satisfies a class: '" + std.getName(unit) + "'");
                            continue;
                        }
                        else if (std instanceof Interface) {
                            if (td.isDynamic() && !std.isDynamic()) {
                                st.addError("dynamic interface satisfies a non-dynamic interface: '" +
                                        std.getName(unit) + "'");
                            }
                        }
                        else {
                            st.addError("satisfied type must be an interface");
                            continue;
View Full Code Here

    }*/

    @Override
    public void visit(Tree.CaseTypes that) {
        super.visit(that);
        TypeDeclaration td = (TypeDeclaration) that.getScope();
        List<BaseMemberExpression> bmes = that.getBaseMemberExpressions();
        List<Tree.StaticType> cts = that.getTypes();
        List<ProducedType> list = new ArrayList<ProducedType>(bmes.size()+cts.size());
        if (td instanceof TypeParameter) {
            if (!bmes.isEmpty()) {
                that.addError("cases of type parameter must be a types");
            }
        }
        else {
            for (Tree.BaseMemberExpression bme: bmes) {
                //bmes have not yet been resolved
                TypedDeclaration od = getTypedDeclaration(bme.getScope(),
                        name(bme.getIdentifier()), null, false, bme.getUnit());
                if (od!=null) {
                    ProducedType type = od.getType();
                    if (type!=null) {
                        list.add(type);
                    }
                }
            }
        }
        for (Tree.StaticType st: cts) {
            ProducedType type = st.getTypeModel();
            if (type!=null) {
                TypeDeclaration ctd = type.getDeclaration();
                if (ctd!=null) {
                    if (ctd instanceof UnionType || ctd instanceof IntersectionType) {
                        //union/intersection types don't have equals()
                        if (td instanceof TypeParameter) {
                            st.addError("enumerated bound must be a class or interface type");
                        }
                        else {
                            st.addError("case type must be a class, interface, or self type");
                        }
                    }
                    else if (ctd.equals(td)) {
                        st.addError("directly enumerates itself: '" + td.getName() + "'");
                        continue;
                    }
                    else if (ctd instanceof TypeParameter) {
                        if (!(td instanceof TypeParameter)) {
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.typechecker.model.TypeDeclaration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.