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

Examples of com.redhat.ceylon.compiler.typechecker.model.ProducedType$Criteria


            }*/
        }
    }

    private void visitThenOperator(Tree.ThenOp that) {
        ProducedType lhst = leftType(that);
        ProducedType rhst = rightType(that);
        if (!isTypeUnknown(lhst)) {
            checkAssignable(lhst, unit.getType(unit.getBooleanDeclaration()), that.getLeftTerm(),
                    "operand expression must be a boolean value");
        }
        if ( rhst!=null && !isTypeUnknown(rhst)) {
View Full Code Here


            that.setTypeModel(unit.getOptionalType(unit.denotableType(rhst)));
        }
    }

    private void visitInOperator(Tree.InOp that) {
        ProducedType lhst = leftType(that);
        ProducedType rhst = rightType(that);
        if (!isTypeUnknown(rhst) && !isTypeUnknown(lhst)) {
            ProducedType ct = checkSupertype(rhst,unit.getCategoryDeclaration(),
                that.getRightTerm(), "operand expression must be a category");
            if (ct!=null) {
                ProducedType at = ct.getTypeArguments().isEmpty() ?
                        null : ct.getTypeArgumentList().get(0);
              checkAssignable(lhst, at, that.getLeftTerm(),
                  "operand expression must be assignable to category type");
            }
        }
View Full Code Here

        that.setTypeModel( unit.getType(unit.getBooleanDeclaration()) );
    }
   
    private void visitUnaryOperator(Tree.UnaryOperatorExpression that,
            TypeDeclaration type) {
        ProducedType t = type(that);
        if (!isTypeUnknown(t)) {
            ProducedType nt = checkSupertype(t, type, that.getTerm(),
                    "operand expression must be of correct type");
            if (nt!=null) {
                ProducedType at = nt.getTypeArguments().isEmpty() ?
                        nt : nt.getTypeArgumentList().get(0);
                that.setTypeModel(at);
            }
        }
    }
View Full Code Here

    }
   
    private void visitOfOperator(Tree.OfOp that) {
        Tree.Type rt = that.getType();
        if (rt!=null) {
            ProducedType t = rt.getTypeModel();
            if (!isTypeUnknown(t)) {
                that.setTypeModel(t);
                Tree.Term tt = that.getTerm();
                if (tt!=null) {
                    if (tt!=null) {
                        ProducedType pt = tt.getTypeModel();
                        if (!isTypeUnknown(pt)) {
                            if (!t.covers(pt)) {
                                that.addError("specified type does not cover the cases of the operand expression: '" +
                                        t.getProducedTypeName(unit) + "' does not cover '" +
                                        pt.getProducedTypeName(unit) + "'");
                            }
                        }
                    }
                }
            }
View Full Code Here

    }
   
    private void visitIsOperator(Tree.IsOp that) {
        Tree.Type rt = that.getType();
        if (rt!=null) {
            ProducedType t = rt.getTypeModel();
            if (t!=null) {
                if (that.getTerm()!=null) {
                    ProducedType pt = that.getTerm().getTypeModel();
                    if (pt!=null && pt.isSubtypeOf(t)) {
                        that.addError("expression type is a subtype of the type: '" +
                                pt.getProducedTypeName(unit) + "' is assignable to '" +
                                t.getProducedTypeName(unit) + "'");
                    }
                    else {
                        if (intersectionType(t, pt, unit).isNothing()) {
                            that.addError("tests assignability to bottom type 'Nothing': intersection of '" +
                                    pt.getProducedTypeName(unit) + "' and '" +
                                    t.getProducedTypeName(unit) + "' is empty");
                        }
                    }
                }
            }
View Full Code Here

        boolean notDirectlyInvoked = !that.getDirectlyInvoked();
        TypedDeclaration member =
                resolveQualifiedMemberExpression(that, notDirectlyInvoked);
        if (member!=null && notDirectlyInvoked) {
            Tree.TypeArguments tal = that.getTypeArguments();
            ProducedType pt =
                    that.getPrimary().getTypeModel()
                    .resolveAliases(); //TODO: probably not necessary
            List<ProducedType> typeArgs;
            if (explicitTypeArguments(member, tal)) {
                typeArgs = getTypeArguments(tal,
View Full Code Here

    private TypedDeclaration resolveQualifiedMemberExpression(
            Tree.QualifiedMemberExpression that,
            boolean error) {
        Tree.Primary p = that.getPrimary();
        ProducedType pt = p.getTypeModel();
        boolean packageQualified = p instanceof Tree.Package;
        boolean check = packageQualified ||
                //that.getStaticMethodReference() ||
                pt!=null &&
                //account for dynamic blocks
                (!pt.getType().isUnknown() ||
                        that.getMemberOperator() instanceof Tree.SpreadOp);
        boolean nameNonempty = that.getIdentifier()!=null &&
                        !that.getIdentifier().getText().equals("");
        if (nameNonempty && check) {
            TypedDeclaration member;
            String name = name(that.getIdentifier());
            String container;
            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)) {
View Full Code Here

    }
   
    private void visitQualifiedMemberExpression(Tree.QualifiedMemberExpression that,
            ProducedType receivingType, TypedDeclaration member,
            List<ProducedType> typeArgs, Tree.TypeArguments tal) {
        ProducedType receiverType =
                accountForStaticReferenceReceiverType(that,
                        unwrap(receivingType, that));
        if (acceptsTypeArguments(receiverType, member, typeArgs, tal, that, false)) {
            ProducedTypedReference ptr =
                    receiverType.getTypedMember(member, typeArgs,
                            that.getAssigned());
            /*if (ptr==null) {
                that.addError("member method or attribute does not exist: " +
                        member.getName(unit) + " of type " +
                        receiverType.getDeclaration().getName(unit));
            }
            else {*/
            that.setTarget(ptr);
            ProducedType fullType =
                    ptr.getFullType(wrap(ptr.getType(), receivingType, that));
            if (!dynamic && !isAbstraction(member) &&
                    isTypeUnknown(fullType)) {
                //this occurs with an ambiguous reference
                //to a member of an intersection type
View Full Code Here

   
    private void visitBaseMemberExpression(Tree.StaticMemberOrTypeExpression that,
            TypedDeclaration member, List<ProducedType> typeArgs,
            Tree.TypeArguments tal) {
        if (acceptsTypeArguments(member, typeArgs, tal, that, false)) {
            ProducedType outerType =
                    that.getScope().getDeclaringType(member);
            ProducedTypedReference pr =
                    member.getProducedTypedReference(outerType, typeArgs,
                            that.getAssigned());
            that.setTarget(pr);
            ProducedType fullType = pr.getFullType();
            if (!dynamic && !isAbstraction(member) &&
                    isTypeUnknown(fullType)) {
                that.addError("could not determine type of function or value reference: '" +
                        member.getName(unit) + "'");
            }
View Full Code Here

        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,
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.typechecker.model.ProducedType$Criteria

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.