Package com.sun.tools.javac.code

Examples of com.sun.tools.javac.code.Type$ErrorType


   /** Converts this into a "set or relation" if possible; otherwise, returns an Expr with a nonempty error list */
   public final Expr typecheck_as_set() {
      if (!errors.isEmpty() || type.size()>0) return this;
      if (Type.INT2SIGINT && type.is_int) return cast2sigint();
      String msg = "This must be a set or relation.\nInstead, it has the following possible type(s):\n"+type;
      return NOOP.make(null, this, new ErrorType(span(), msg), 0);
   }
View Full Code Here


   /** Convenience method that generates a type error with "msg" as the message,
    * and includes the left and right bounding types in the message.
    */
   private static ErrorType error(Pos pos, String msg, Expr left, Expr right) {
      return new ErrorType(pos, msg+"\nLeft type = "+left.type+"\nRight type = "+right.type);
   }
View Full Code Here

        } else {
            newBody = newBody.typecheck_as_set();
            if (newBody.ambiguous) newBody = newBody.resolve_as_set(null);
            if (newBody.errors.size()>0) throw newBody.errors.pick();
            if (newBody.type.arity() != returnDecl.type.arity())
               throw new ErrorType(newBody.span(),
               "Function return type is "+returnDecl.type+",\nso the body must be a relation with arity "
               +returnDecl.type.arity()+".\nSo the body's type cannot be: "+newBody.type);
        }
        if (newBody.mult!=0) throw new ErrorSyntax(newBody.span(), "Multiplicity expression not allowed here.");
        this.body = newBody;
View Full Code Here

           "perhaps you used ( ) when you should have used [ ]\n");
        for(Expr x:choices) {
            pos = pos.merge(x.span());
            if (x instanceof ExprBadCall || x instanceof ExprBadJoin) sb.append('\n').append(x.errors.pick().msg);
        }
        return new ErrorType(pos, sb.toString());
    }
View Full Code Here

    //============================================================================================================//

    /** Construct an ExprChoice node. */
    public static Expr make(Pos pos, ConstList<Expr> choices, ConstList<String> reasons) {
        if (choices.size()==0) return new ExprBad(pos, "", new ErrorType(pos, "This expression failed to be typechecked."));
        if (choices.size()==1 && choices.get(0).errors.isEmpty()) return choices.get(0); // Shortcut
        Type type=EMPTY;
        boolean first=true;
        long weight=0;
        for(Expr x:choices) {
View Full Code Here

            txt="\nThis name cannot be resolved; its relevant type does not intersect with any of the following candidates:";
            re = reasons;
        }
        StringBuilder msg = new StringBuilder(txt);
        for(String r:re) msg.append('\n').append(r);
        return new ExprBad(pos, toString(), new ErrorType(pos, msg.toString()));
    }
View Full Code Here

    }

    /** {@inheritDoc} */
    @Override final<T> T accept(VisitReturn<T> visitor) throws Err {
        if (!errors.isEmpty()) throw errors.pick();
        throw new ErrorType(span(), "This expression failed to be resolved.");
    }
View Full Code Here

    }

    /** Return the relational join between this and that (throws ErrorType if this.arity==1 and that.arity==1) */
    public SimTupleset join(SimTupleset that) throws ErrorType {
       if (empty() || that.empty()) return EMPTY;
       if (arity()==1 && that.arity()==1) throw new ErrorType("Cannot join two unary relations.");
       TempList<SimTuple> ans = new TempList<SimTuple>();
       for(SimTuple a: this) for(SimTuple b: that) if (a.tail()==b.head()) {
          SimTuple c = a.join(b);
          if (!ans.contains(c)) ans.add(c);
       }
View Full Code Here

            ambiguous = ambiguous || x.ambiguous;
            errs = errs.make(x.errors);
            weight = weight + x.weight;
            if (x.mult!=0) errs = errs.make(new ErrorSyntax(x.span(), "Multiplicity expression not allowed here."));
            if (a>0 && x.errors.isEmpty() && !x.type.hasArity(a))
              errs = errs.make(new ErrorType(x.span(), "This should have arity "+a+" but instead its possible type(s) are "+x.type));
            newargs.add(x);
        }
        Type t=Type.FORMULA;
        if (!fun.isPred && errs.size()==0) {
            final Type tt = fun.returnDecl.type;
View Full Code Here

        }
        if (op==Op.TOTALORDER) {
           if (newargs.size()!=3) {
              errs = errs.make(new ErrorSyntax(pos, "The builtin pred/totalOrder[] predicate must be called with exactly three arguments."));
           } else if (errs.isEmpty()) {
              if (!newargs.get(0).type.hasArity(1)) errs = errs.make(new ErrorType(pos, "The first argument to pred/totalOrder must be unary."));
              if (!newargs.get(1).type.hasArity(1)) errs = errs.make(new ErrorType(pos, "The second argument to pred/totalOrder must be unary."));
              if (!newargs.get(2).type.hasArity(2)) errs = errs.make(new ErrorType(pos, "The third argument to pred/totalOrder must be binary."));
           }
        }
        if (op==Op.DISJOINT) {
           if (newargs.size()<2) errs = errs.make(new ErrorSyntax(pos, "The builtin disjoint[] predicate must be called with at least two arguments."));
           if (commonArity==EMPTY) errs = errs.make(new ErrorType(pos, "The builtin predicate disjoint[] cannot be used among expressions of different arities."));
        }
        return new ExprList(pos, closingBracket, op, ambiguous, newargs.makeConst(), weight, errs);
    }
View Full Code Here

TOP

Related Classes of com.sun.tools.javac.code.Type$ErrorType

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.