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

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


    private TypeDeclaration resolveQualifiedTypeExpression(
            Tree.QualifiedTypeExpression 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.isUnknown() ||
                        that.getMemberOperator() instanceof Tree.SpreadOp);
        if (check) {
            TypeDeclaration type;
            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 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)) {
View Full Code Here


   
    @Override public void visit(Tree.SimpleType that) {
        //this one is a declaration, not an expression!
        //we are only validating type arguments here
        super.visit(that);
        ProducedType pt = that.getTypeModel();
        if (pt!=null) {
            TypeDeclaration type = that.getDeclarationModel();//pt.getDeclaration()
            Tree.TypeArgumentList tal = that.getTypeArgumentList();
            //No type inference for declarations
            if (type!=null) {
                List<TypeParameter> params = type.getTypeParameters();
                List<ProducedType> ta = getTypeArguments(tal,
                        params, pt.getQualifyingType());
                acceptsTypeArguments(type, ta, tal, that, that.getMetamodel());
                //the type has already been set by TypeVisitor
                if (tal!=null) {
                    List<Tree.Type> args = tal.getTypes();
                    for (int i = 0; i<args.size(); i++) {
                        Tree.Type t = args.get(i);
                        if (t instanceof Tree.StaticType) {
                            TypeVariance variance =
                                    ((Tree.StaticType) t).getTypeVariance();
                            if (variance!=null) {
                                TypeParameter p = params.get(i);
                                if (p.isInvariant()) {
                                    if (variance.getText().equals("out")) {
                                        pt.setVariance(p, OUT);
                                    }
                                    else if (variance.getText().equals("in")) {
                                        pt.setVariance(p, IN);
                                    }
                                }
                                else {
                                    variance.addError("type parameter is not declared invariant: '" +
                                            p.getName() + "' of '" + type.getName(unit) + "'");
View Full Code Here

    }

    private void visitQualifiedTypeExpression(Tree.QualifiedTypeExpression that,
            ProducedType receivingType, TypeDeclaration memberType,
            List<ProducedType> typeArgs, Tree.TypeArguments tal) {
        ProducedType receiverType =
                accountForStaticReferenceReceiverType(that,
                        unwrap(receivingType, that));
        if (acceptsTypeArguments(receiverType, memberType, typeArgs, tal, that, false)) {
            ProducedType type = receiverType.getTypeMember(memberType, typeArgs);
            that.setTarget(type);
            ProducedType fullType =
                    type.getFullType(wrap(type, receivingType, that));
            if (!dynamic && !that.getStaticMethodReference() &&
                    memberType instanceof Class &&
                    !isAbstraction(memberType) &&
                    isTypeUnknown(fullType)) {
View Full Code Here

    private void visitBaseTypeExpression(Tree.StaticMemberOrTypeExpression that,
            TypeDeclaration baseType, List<ProducedType> typeArgs,
            Tree.TypeArguments tal) {
        if (acceptsTypeArguments(baseType, typeArgs, tal, that, false)) {
            ProducedType outerType =
                    that.getScope().getDeclaringType(baseType);
            ProducedType type =
                    baseType.getProducedType(outerType, typeArgs);
            ProducedType fullType = type.getFullType();
            that.setTypeModel(fullType);
            that.setTarget(type);
        }
    }
View Full Code Here

        Tree.Term term = that.getTerm();
        if (term==null) {
            that.addError("expression not well formed");
        }
        else {
            ProducedType t = term.getTypeModel();
            if (t==null) {
                //that.addError("could not determine type of expression");
            }
            else {
                that.setTypeModel(t);
View Full Code Here

            }
        }
    }
   
    @Override public void visit(Tree.Outer that) {
        ProducedType ci = getOuterClassOrInterface(that.getScope());
        if (ci==null) {
            that.addError("outer appears outside a nested class or interface definition");
        }
        else {
            that.setTypeModel(ci);
View Full Code Here

        }
    }
   
    @Override public void visit(Tree.Tuple that) {
        super.visit(that);
        ProducedType tt = null;
        Tree.SequencedArgument sa = that.getSequencedArgument();
        if (sa!=null) {
            tt = getTupleType(sa.getPositionalArguments(), unit, true);
        }
        else {
            tt = unit.getType(unit.getEmptyDeclaration());
        }
        if (tt!=null) {
            that.setTypeModel(tt);
            if (tt.containsUnknowns()) {
                that.addError("tuple element type could not be inferred");
            }
        }
    }
View Full Code Here

        }
    }

    @Override public void visit(Tree.SequenceEnumeration that) {
        super.visit(that);
        ProducedType st = null;
        Tree.SequencedArgument sa = that.getSequencedArgument();
        if (sa!=null) {
            ProducedType tt = getTupleType(sa.getPositionalArguments(), unit, false);
            if (tt!=null) {
                st = tt.getSupertype(unit.getIterableDeclaration());
                if (st==null) {
                    st = unit.getIterableType(new UnknownType(unit).getType());
                }
            }
        }
View Full Code Here

        super.visit(that);
        Tree.Variable var = that.getVariable();
        if (var!=null) {
            Tree.Type vt = var.getType();
            if (vt instanceof Tree.LocalModifier) {
                ProducedType et = unit.getType(unit.getExceptionDeclaration());
                vt.setTypeModel(et);
                var.getDeclarationModel().setType(et);
            }
            else {
                ProducedType tt = unit.getType(unit.getThrowableDeclaration());
                checkAssignable(vt.getTypeModel(), tt, vt,
                        "catch type must be a throwable type");
//                TypeDeclaration d = vt.getTypeModel().getDeclaration();
//                if (d instanceof IntersectionType) {
//                    vt.addUnsupportedError("intersection types in catch not yet supported");
View Full Code Here

    }
   
    @Override public void visit(Tree.StringTemplate that) {
        super.visit(that);
        for (Tree.Expression e: that.getExpressions()) {
            ProducedType et = e.getTypeModel();
            if (!isTypeUnknown(et)) {
                checkAssignable(et, unit.getType(unit.getObjectDeclaration()), e,
                        "interpolated expression must not be an optional type");
            }
        }
View Full Code Here

TOP

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

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.