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

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


   
    private void visitIdentityOperator(Tree.BinaryOperatorExpression that) {
        ProducedType lhst = leftType(that);
        ProducedType rhst = rightType(that);
        if (!isTypeUnknown(rhst) && !isTypeUnknown(lhst)) {
            TypeDeclaration id = unit.getIdentifiableDeclaration();
            checkAssignable(lhst, id.getType(), that.getLeftTerm(),
                    "operand expression must be of type 'Identifiable'");
            checkAssignable(rhst, id.getType(), that.getRightTerm(),
                    "operand expression must be of type 'Identifiable'");
            if (intersectionType(lhst, rhst, unit).isNothing()) {
                that.addError("values of disjoint types are never identical: '" +
                        lhst.getProducedTypeName(unit) +
                        "' has empty intersection with '" +
View Full Code Here


   
    private void visitEqualityOperator(Tree.BinaryOperatorExpression that) {
        ProducedType lhst = leftType(that);
        ProducedType rhst = rightType(that);
        if (!isTypeUnknown(rhst) && !isTypeUnknown(lhst)) {
            TypeDeclaration od = unit.getObjectDeclaration();
            checkAssignable(lhst, od.getType(), that.getLeftTerm(),
                    "operand expression must be of type Object");
            checkAssignable(rhst, od.getType(), that.getRightTerm(),
                    "operand expression must be of type Object");
        }
        that.setTypeModel(unit.getType(unit.getBooleanDeclaration()));
    }
View Full Code Here

            TypeDeclaration type) {
        ProducedType lhst = leftType(that);
        ProducedType rhst = rightType(that);
        if (!isTypeUnknown(rhst) && !isTypeUnknown(lhst)) {
            //hardcoded implicit type conversion Integer->Float
            TypeDeclaration fd = unit.getFloatDeclaration();
            TypeDeclaration id = unit.getIntegerDeclaration();
            if (rhst.getDeclaration().inherits(fd) &&
                lhst.getDeclaration().inherits(id)) {
                lhst = fd.getType();
            }
            else if (rhst.getDeclaration().inherits(id) &&
View Full Code Here

            TypeDeclaration type) {
        ProducedType lhst = leftType(that);
        ProducedType rhst = rightType(that);
        if (!isTypeUnknown(rhst) && !isTypeUnknown(lhst)) {
            //hardcoded implicit type conversion Integer->Float
            TypeDeclaration fd = unit.getFloatDeclaration();
            TypeDeclaration id = unit.getIntegerDeclaration();
            if (rhst.getDeclaration().inherits(id) &&
                lhst.getDeclaration().inherits(fd)) {
                rhst = fd.getType();
            }
            ProducedType nt = checkSupertype(lhst, type, that.getLeftTerm(),
View Full Code Here

    }
   
    @Override
    public void visit(Tree.BaseType that) {
        super.visit(that);
        TypeDeclaration type = that.getDeclarationModel();
        if (type!=null) {
            if (!type.isVisible(that.getScope())) {
                that.addError("type is not visible: " +
                        baseDescription(that), 400);
            }
            else if (type.isPackageVisibility() &&
                    !declaredInPackage(type, unit)) {
                that.addError("package private type is not visible: " +
                    baseDescription(that));
            }
            //don't need to consider "protected" because
View Full Code Here

    }

    @Override
    public void visit(Tree.QualifiedType that) {
        super.visit(that);
        TypeDeclaration type = that.getDeclarationModel();
        if (type!=null) {
            if (!type.isVisible(that.getScope())) {
                that.addError("member type is not visible: " +
                        qualifiedDescription(that), 400);
            }
            else if (type.isPackageVisibility() &&
                    !declaredInPackage(type, unit)) {
                that.addError("package private member type is not visible: " +
                        qualifiedDescription(that));
            }
            //this is actually slightly too restrictive
            //since a qualified type may in fact be an
            //inherited member type, but in that case
            //you can just get rid of the qualifier, so
            //in fact this restriction is OK
            else if (type.isProtectedVisibility() &&
                    !declaredInPackage(type, unit)) {
                that.addError("protected member type is not visible: " +
                        qualifiedDescription(that));
            }
            //Note: we should remove this check if we ever
View Full Code Here

                }
                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 {
                        member = getTypedMember(d, name, signature, ellipsis, unit);
                    }
                }
                else {
                    member = getTypedMember(d, name, signature, ellipsis, unit);
                }
                ambiguous = member==null &&
                        d.isMemberAmbiguous(name, unit, signature, ellipsis);
            }
            if (member==null) {
                if (error) {
                    if (ambiguous) {
                        that.addError("method or attribute is ambiguous: '" +
View Full Code Here

    }

    @Override public void visit(Tree.BaseTypeExpression that) {
        super.visit(that);
        boolean notDirectlyInvoked = !that.getDirectlyInvoked();
        TypeDeclaration type =
                resolveBaseTypeExpression(that, notDirectlyInvoked);
        if (type!=null && notDirectlyInvoked) {
            Tree.TypeArguments tal = that.getTypeArguments();
            List<ProducedType> typeArgs;
            if (explicitTypeArguments(type, tal)) {
                typeArgs = getTypeArguments(tal,
                        type.getTypeParameters(), null);
            }
            else {
                typeArgs = inferFunctionRefTypeArgs(that);
            }
            if (typeArgs!=null) {
View Full Code Here

    private TypeDeclaration resolveBaseTypeExpression(
            Tree.BaseTypeExpression that,
            boolean error) {
        String name = name(that.getIdentifier());
        TypeDeclaration type = getTypeDeclaration(that.getScope(),
                name, that.getSignature(), that.getEllipsis(),
                that.getUnit());
        if (type==null) {
            if (!dynamic && error) {
                that.addError("type does not exist: '" + name + "'", 102);
View Full Code Here

    }
   
    @Override public void visit(Tree.QualifiedTypeExpression that) {
        super.visit(that);
        boolean notDirectlyInvoked = !that.getDirectlyInvoked();
        TypeDeclaration type =
                resolveQualifiedTypeExpression(that, notDirectlyInvoked);
        if (type!=null && notDirectlyInvoked) {
            Tree.TypeArguments tal = that.getTypeArguments();
            ProducedType pt =
                    that.getPrimary().getTypeModel()
                    .resolveAliases(); //TODO: probably not necessary
            List<ProducedType> typeArgs;
            if (explicitTypeArguments(type, tal)) {
                typeArgs = getTypeArguments(tal,
                        type.getTypeParameters(), pt);
            }
            else {
                typeArgs = inferFunctionRefTypeArgs(that);
            }
            if (typeArgs!=null) {
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.