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

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


    @Override
    public void visit(Tree.MatchCase that) {
        super.visit(that);
        for (Tree.Expression e: that.getExpressionList().getExpressions()) {
            if (e!=null) {
                ProducedType t = e.getTypeModel();
                if (!isTypeUnknown(t)) {
                    if (switchExpression!=null) {
                        ProducedType st = switchExpression.getTypeModel();
                        if (!isTypeUnknown(st)) {
                            if (!hasUncheckedNulls(switchExpression.getTerm()) || !isNullCase(t)) {
                                checkAssignable(t, st, e,
                                        "case must be assignable to switch expression type");
                            }
                        }
                    }
                    Tree.Term term = e.getTerm();
                    if (term instanceof Tree.NegativeOp) {
                        term = ((Tree.NegativeOp) term).getTerm();
                    }
                    if (term instanceof Tree.Literal) {
                        if (term instanceof Tree.FloatLiteral) {
                            e.addError("literal case may not be a 'Float' literal");
                        }
                    }
                    else if (term instanceof Tree.MemberOrTypeExpression) {
                        ProducedType ut = unionType(unit.getType(unit.getNullDeclaration()),
                                unit.getType(unit.getIdentifiableDeclaration()), unit);
                        TypeDeclaration dec = t.getDeclaration();
                        if ((!dec.isToplevel() && !dec.isStaticallyImportable()) || !dec.isAnonymous()) {
                            e.addError("case must refer to a toplevel object declaration or literal value");
                        }
View Full Code Here


        }
    }
   
  private ProducedType narrow(Tree.IsCondition that, ProducedType type,
            ProducedType knownType) {
      ProducedType it;
      if (that.getNot()) {
          //a !is condition, narrow to complement
          it = unit.denotableType(knownType.minus(type));
      }
      else {
View Full Code Here

    @Override public void visit(Tree.ExistsOrNonemptyCondition that) {
        //don't recurse to the Variable, since we don't
        //want to check that the specifier expression is
        //assignable to the declared variable type
        //(nor is it possible to infer the variable type)
        ProducedType t = null;
        Node n = that;
        Tree.Term term = null;
        Tree.Variable v = that.getVariable();
        if (v!=null) {
            //v.getType().visit(this);
View Full Code Here

    }

    @Override public void visit(Tree.BooleanCondition that) {
        super.visit(that);
        if (that.getExpression()!=null) {
            ProducedType t = that.getExpression().getTypeModel();
            if (!isTypeUnknown(t)) {
                checkAssignable(t, unit.getType(unit.getBooleanDeclaration()), that,
                        "expression must be of boolean type");
            }
        }
View Full Code Here

        }
    }

    @Override public void visit(Tree.Resource that) {
        super.visit(that);
        ProducedType t = null;
        Node typedNode = null;
        Tree.Expression e = that.getExpression();
        Tree.Variable v = that.getVariable();
        if (e!=null) {
            t = e.getTypeModel();
            typedNode = e;
           
        }
        else if (v!=null) {
            t = v.getType().getTypeModel();
            typedNode = v.getType();
            Tree.SpecifierExpression se = v.getSpecifierExpression();
            if (se==null) {
                v.addError("missing resource specifier");
            }
            else {
                e = se.getExpression();
                if (typedNode instanceof Tree.ValueModifier) {
                    typedNode = se.getExpression();
                }
            }
        }
        else {
            that.addError("missing resource expression");
        }
        if (typedNode!=null) {
            if (!isTypeUnknown(t)) {
                if (e != null) {
                    ProducedType ot = unit.getType(unit.getObtainableDeclaration());
                    ProducedType dt = unit.getType(unit.getDestroyableDeclaration());
                    if (isInstantiationExpression(e)) {
                        if (!t.isSubtypeOf(dt) && !t.isSubtypeOf(ot)) {
                            typedNode.addError("resource must be either obtainable or destroyable: '" +
                                    t.getProducedTypeName(unit) + "' is neither 'Obtainable' nor 'Destroyable'");
                        }
View Full Code Here

        super.visit(that);
        Tree.SpecifierExpression se = that.getSpecifierExpression();
        if (se!=null) {
            Tree.Expression e = se.getExpression();
            if (e!=null) {
                ProducedType et = e.getTypeModel();
                if (!isTypeUnknown(et)) {
                    if (!unit.isIterableType(et)) {
                        se.addError("expression is not iterable: '" +
                                et.getProducedTypeName(unit) +
                                "' is not a subtype of 'Iterable'");
                    }
                    else if (et!=null && unit.isEmptyType(et)) {
                        se.addError("iterated expression is definitely empty: '" +
                                et.getProducedTypeName(unit) +
                                "' is a subtype of 'Empty'");
                    }
                }
            }
        }
View Full Code Here

        super.visit(that);
        Tree.SpecifierExpression se = that.getSpecifierExpression();
        if (se!=null) {
            Tree.Expression e = se.getExpression();
            if (e!=null) {
                ProducedType et = e.getTypeModel();
                if (!isTypeUnknown(et)) {
                    ProducedType it = unit.getIteratedType(et);
                    if (it!=null && !isTypeUnknown(it)) {
                        if (!unit.isEntryType(it)) {
                            se.addError("iterated element type is not an entry type: '" +
                                    it.getProducedTypeName(unit) +
                                    "' is not a subtype of 'Entry'");
                        }
                    }
                }
            }
View Full Code Here

        Tree.SpecifierOrInitializerExpression sie =
                that.getSpecifierOrInitializerExpression();
        inferType(that, sie);
        Tree.Type type = that.getType();
        if (type!=null) {
          ProducedType t = type.getTypeModel();
          if (type instanceof Tree.LocalModifier) {
            if (dec.isParameter()) {
              type.addError("parameter may not have inferred type: '" +
                  dec.getName() + "' must declare an explicit type");
            }
View Full Code Here

                    p instanceof Tree.BaseMemberExpression) {
                Tree.MemberOrTypeExpression mte =
                        (Tree.MemberOrTypeExpression) p;
                if (p.getTypeModel()!=null &&
                        mte.getDeclaration()!=null) {
                    ProducedType pt = p.getTypeModel();
                    if (pt!=null) {
                        for (int j=0; j<that.getParameterLists().size(); j++) {
                            Tree.ParameterList pl =
                                    that.getParameterLists().get(j);
                            ProducedType ct =
                                    pt.getSupertype(unit.getCallableDeclaration());
                            String refName =
                                    mte.getDeclaration().getName();
                            if (ct==null) {                       
                                pl.addError("no matching parameter list in referenced declaration: '" +
                                        refName + "'");
                            }
                            else if (ct.getTypeArgumentList().size()>=2) {
                                ProducedType tupleType =
                                        ct.getTypeArgumentList().get(1);
                                List<ProducedType> argTypes =
                                        unit.getTupleElementTypes(tupleType);
                                boolean variadic =
                                        unit.isTupleLengthUnbounded(tupleType);
                                boolean atLeastOne =
                                        unit.isTupleVariantAtLeastOne(tupleType);
                                List<Tree.Parameter> params = pl.getParameters();
                                if (argTypes.size()!=params.size()) {
                                    pl.addError("wrong number of declared parameters: '" +
                                            refName  + "' has " + argTypes.size() +
                                            " parameters");
                                }
                                for (int i=0; i<argTypes.size()&&i<params.size(); i++) {
                                    ProducedType at = argTypes.get(i);
                                    Tree.Parameter param = params.get(i);
                                    ProducedType t = param.getParameterModel().getModel()
                                            .getTypedReference()
                                            .getFullType();
                                    String paramName = param.getParameterModel().getName();
                                    checkAssignable(at, t, param,
                                            "type of parameter '" + paramName +
View Full Code Here

                if (d instanceof Value &&
                        sie instanceof Tree.LazySpecifierExpression) {
                    ((Value) d).setTransient(true);
                }
               
                ProducedType t = that.getBaseMemberExpression().getTypeModel();
                if (that.getBaseMemberExpression()==me && d instanceof Method) {
                    //if the declaration of the method has
                    //defaulted parameters, we should ignore
                    //that when determining if the RHS is
                    //an acceptable implementation of the
View Full Code Here

TOP

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

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.