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

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


    private void checkAssignability(Tree.Term that, Node node) {
        if (that instanceof Tree.QualifiedMemberOrTypeExpression ||
            that instanceof Tree.BaseMemberOrTypeExpression) {
            Tree.StaticMemberOrTypeExpression smte =
                    (Tree.StaticMemberOrTypeExpression) that;
            Declaration dec = smte.getDeclaration();
            if (dec!=null &&
                    (!isEffectivelyBaseMemberExpression(smte) ||
                     !unit.equals(dec.getUnit()))) { //Note: other cases handled in SpecificationVisitor
                if (dec instanceof Value) {
                    Value value = (Value) dec;
                    if (!value.isVariable() && !value.isLate()) {
                        that.addError("value is not a variable: '" +
                                dec.getName(unit) + "'", 800);
                    }
                }
                else {
                    that.addError("not a variable value: '" +
                            dec.getName(unit) + "'");
                }
            }
            if (that instanceof Tree.QualifiedMemberOrTypeExpression) {
                Tree.QualifiedMemberOrTypeExpression qmte =
                        (Tree.QualifiedMemberOrTypeExpression) that;
View Full Code Here


        if (isOverloadedVersion(type)) { 
            //it is a Java constructor
            //get the actual type that
            //owns the constructor
            //Declaration at = type.getContainer().getDirectMember(type.getName(), null, false);
            Declaration at = type.getExtendedTypeDeclaration();
            if (!at.isVisible(that.getScope())) {
                that.addError("type is not visible: '" + name + "'");
            }
            else if (at.isPackageVisibility() &&
                    !declaredInPackage(type, unit)) {
                that.addError("package private type is not visible: '" + name + "'");
            }
            else if (at.isProtectedVisibility() &&
                    !declaredInPackage(type, unit)) {
                that.addError("protected type is not visible: '" + name + "'");
            }
            else if (!type.isVisible(that.getScope())) {
                that.addError("type constructor is not visible: '" + name + "'");
View Full Code Here

        if (isOverloadedVersion(type)) {
            //it is a Java constructor
            //get the actual type that
            //owns the constructor
            //Declaration at = type.getContainer().getDirectMember(type.getName(), null, false);
            Declaration at = type.getExtendedTypeDeclaration();
            if (!at.isVisible(that.getScope())) {
                that.addError("member type is not visible: '" +
                        name + "' of '" + container);
            }
            else if (at.isPackageVisibility() &&
                    !declaredInPackage(type, unit)) {
                that.addError("package private member type is not visible: '" +
                        name + "' of type " + container);
            }
            else if (at.isProtectedVisibility() &&
                    !declaredInPackage(type, unit)) {
                that.addError("protected member type is not visible: '" +
                        name + "' of type " + container);
            }
            else if (!type.isVisible(that.getScope())) {
View Full Code Here

        return "'" + name(that.getIdentifier()) +"'";
    }
   
    private static String qualifiedDescription(Tree.QualifiedType that) {
        String name = name(that.getIdentifier());
        Declaration d = that.getOuterType().getTypeModel().getDeclaration();
        return "'" + name + "' of type '" + d.getName() + "'";
    }
View Full Code Here

            boolean ambiguous;
            List<ProducedType> signature = that.getSignature();
            boolean ellipsis = that.getEllipsis();
            if (packageQualified) {
                container = "package '" + unit.getPackage().getNameAsString() + "'";
                Declaration pm = unit.getPackage()
                        .getMember(name, signature, ellipsis);
                if (pm instanceof TypedDeclaration) {
                    member = (TypedDeclaration) pm;
                }
                else {
                    member = null;
                }
                ambiguous = false;
            }
            else {
                pt = pt.resolveAliases(); //needed for aliases like "alias Id<T> => T"
                TypeDeclaration d = getDeclaration(that, pt);
                container = "type '" + d.getName(unit) + "'";
                ClassOrInterface ci =
                        getContainingClassOrInterface(that.getScope());
                if (ci!=null && d.inherits(ci) && !(d instanceof NothingType)) {
                    Declaration direct =
                            ci.getDirectMember(name, signature, ellipsis);
                    if (direct instanceof TypedDeclaration) {
                        member = (TypedDeclaration) direct;
                    }
                    else {
View Full Code Here

          return true;
      }
    }
   
   void visitExtendedTypePrimary(Tree.ExtendedTypeExpression that) {
        Declaration dec = that.getDeclaration();
        if (dec instanceof Class) {
            Class c = (Class) dec;
            if (c.isAbstraction()) {
                //if the constructor is overloaded
                //resolve the right overloaded version
                Declaration result =
                        findMatchingOverloadedClass(c,
                                that.getSignature(),
                                that.getEllipsis());
                if (result!=null && result!=dec) {
                    //patch the reference, which was already
                    //initialized to the abstraction
                    that.setDeclaration((TypeDeclaration) result);
                    if (isOverloadedVersion(result)) { 
                        //it is a Java constructor
                        if (result.isPackageVisibility() &&
                                !declaredInPackage(result, unit)) {
                            that.addError("package private constructor is not visible: '" +
                                    result.getName() + "'");
                        }
                    }
                }
                //else report to user that we could not
                //find a matching overloaded constructor
View Full Code Here

            while (p instanceof Tree.Expression &&
                    p.getMainToken()==null) { //this hack allows actual parenthesized expressions through
                p = ((Tree.Expression) p).getTerm();
            }
            if (p instanceof Tree.MemberOrTypeExpression) {
                Declaration pd = ((Tree.MemberOrTypeExpression) p).getDeclaration();
                if (!(that.getStaticMethodReference()) &&
                        pd instanceof Functional) {
                    //this is a direct function ref
                    //its not a type, it can't have members
                    that.addError("direct function references do not have members");
View Full Code Here

            boolean ambiguous;
            List<ProducedType> signature = that.getSignature();
            boolean ellipsis = that.getEllipsis();
            if (packageQualified) {
                container = "package '" + unit.getPackage().getNameAsString() + "'";
                Declaration pm = unit.getPackage()
                        .getMember(name, signature, ellipsis);
                if (pm instanceof TypeDeclaration) {
                    type = (TypeDeclaration) pm;
                }
                else {
                    type = null;
                }
                ambiguous = false;
            }
            else {
                pt = pt.resolveAliases(); //needed for aliases like "alias Id<T> => T"
                TypeDeclaration d = getDeclaration(that, pt);
                container = "type '" + d.getName(unit) + "'";
                ClassOrInterface ci =
                        getContainingClassOrInterface(that.getScope());
                if (ci!=null && d.inherits(ci) && !(d instanceof NothingType)) {
                    Declaration direct =
                            ci.getDirectMember(name, signature, ellipsis);
                    if (direct instanceof TypeDeclaration) {
                        type = (TypeDeclaration) direct;
                    }
                    else {
View Full Code Here

                }
            }
            Set<Declaration> valueSet = new HashSet<Declaration>();
            for (Tree.BaseMemberExpression bme: that.getBaseMemberExpressions()) {
                ProducedType type = bme.getTypeModel();
                Declaration d = bme.getDeclaration();
                if (d!=null && !valueSet.add(d)) {
                    //this error is not really truly necessary
                    bme.addError("duplicate case: '" +
                            d.getName(unit) +
                            "' of '" + td.getName() + "'");
                }
                if (d!=null && type!=null &&
                        !type.getDeclaration().isAnonymous()) {
                    bme.addError("case must be a toplevel anonymous class: '" +
                            d.getName(unit) + "' is not an anonymous class");
                }
                else if (d!=null && !d.isToplevel()) {
                    bme.addError("case must be a toplevel anonymous class: '" +
                            d.getName(unit) + "' is not toplevel");
                }
                if (type!=null) {
                    if (checkDirectSubtype(td, bme, type)) {
                        checkAssignable(type, td.getType(), bme,
                                getCaseTypeExplanation(td, type));
View Full Code Here

  }
 
    @Override
    public void visit(Tree.MemberOrTypeExpression that) {
        super.visit(that);
        Declaration d = that.getDeclaration();
    if (d!=null) referenced(d);
    }
View Full Code Here

TOP

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

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.