src/share/classes/com/sun/tools/javac/comp/Check.java

changeset 89
b6d5f53b3b29
parent 80
5c9cdeb740f2
child 110
91eea580fbe9
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon Aug 04 17:54:15 2008 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Tue Aug 05 12:54:40 2008 +0100
     1.3 @@ -63,6 +63,7 @@
     1.4      private final Target target;
     1.5      private final Source source;
     1.6      private final Types types;
     1.7 +    private final JCDiagnostic.Factory diags;
     1.8      private final boolean skipAnnotations;
     1.9      private final TreeInfo treeinfo;
    1.10  
    1.11 @@ -86,6 +87,7 @@
    1.12          syms = Symtab.instance(context);
    1.13          infer = Infer.instance(context);
    1.14          this.types = Types.instance(context);
    1.15 +        diags = JCDiagnostic.Factory.instance(context);
    1.16          Options options = Options.instance(context);
    1.17          target = Target.instance(context);
    1.18          source = Source.instance(context);
    1.19 @@ -343,7 +345,7 @@
    1.20          if (types.isAssignable(found, req, convertWarner(pos, found, req)))
    1.21              return found;
    1.22          if (found.tag <= DOUBLE && req.tag <= DOUBLE)
    1.23 -            return typeError(pos, JCDiagnostic.fragment("possible.loss.of.precision"), found, req);
    1.24 +            return typeError(pos, diags.fragment("possible.loss.of.precision"), found, req);
    1.25          if (found.isSuperBound()) {
    1.26              log.error(pos, "assignment.from.super-bound", found);
    1.27              return syms.errType;
    1.28 @@ -352,7 +354,7 @@
    1.29              log.error(pos, "assignment.to.extends-bound", req);
    1.30              return syms.errType;
    1.31          }
    1.32 -        return typeError(pos, JCDiagnostic.fragment("incompatible.types"), found, req);
    1.33 +        return typeError(pos, diags.fragment("incompatible.types"), found, req);
    1.34      }
    1.35  
    1.36      /** Instantiate polymorphic type to some prototype, unless
    1.37 @@ -380,7 +382,7 @@
    1.38                  } else {
    1.39                      JCDiagnostic d = ex.getDiagnostic();
    1.40                      return typeError(pos,
    1.41 -                                     JCDiagnostic.fragment("incompatible.types" + (d!=null ? ".1" : ""), d),
    1.42 +                                     diags.fragment("incompatible.types" + (d!=null ? ".1" : ""), d),
    1.43                                       t, pt);
    1.44                  }
    1.45              }
    1.46 @@ -401,7 +403,7 @@
    1.47              return req;
    1.48          } else {
    1.49              return typeError(pos,
    1.50 -                             JCDiagnostic.fragment("inconvertible.types"),
    1.51 +                             diags.fragment("inconvertible.types"),
    1.52                               found, req);
    1.53          }
    1.54      }
    1.55 @@ -480,9 +482,9 @@
    1.56      Type checkClassType(DiagnosticPosition pos, Type t) {
    1.57          if (t.tag != CLASS && t.tag != ERROR)
    1.58              return typeTagError(pos,
    1.59 -                                JCDiagnostic.fragment("type.req.class"),
    1.60 +                                diags.fragment("type.req.class"),
    1.61                                  (t.tag == TYPEVAR)
    1.62 -                                ? JCDiagnostic.fragment("type.parameter", t)
    1.63 +                                ? diags.fragment("type.parameter", t)
    1.64                                  : t);
    1.65          else
    1.66              return t;
    1.67 @@ -515,7 +517,7 @@
    1.68      Type checkReifiableReferenceType(DiagnosticPosition pos, Type t) {
    1.69          if (t.tag != CLASS && t.tag != ARRAY && t.tag != ERROR) {
    1.70              return typeTagError(pos,
    1.71 -                                JCDiagnostic.fragment("type.req.class.array"),
    1.72 +                                diags.fragment("type.req.class.array"),
    1.73                                  t);
    1.74          } else if (!types.isReifiable(t)) {
    1.75              log.error(pos, "illegal.generic.type.for.instof");
    1.76 @@ -540,7 +542,7 @@
    1.77              return t;
    1.78          default:
    1.79              return typeTagError(pos,
    1.80 -                                JCDiagnostic.fragment("type.req.ref"),
    1.81 +                                diags.fragment("type.req.ref"),
    1.82                                  t);
    1.83          }
    1.84      }
    1.85 @@ -560,7 +562,7 @@
    1.86              return t;
    1.87          default:
    1.88              return typeTagError(pos,
    1.89 -                                JCDiagnostic.fragment("type.req.ref"),
    1.90 +                                diags.fragment("type.req.ref"),
    1.91                                  t);
    1.92          }
    1.93      }
    1.94 @@ -1028,7 +1030,7 @@
    1.95       *  @param other  The overridden method.
    1.96       *  @return       An internationalized string.
    1.97       */
    1.98 -    static Object cannotOverride(MethodSymbol m, MethodSymbol other) {
    1.99 +    Object cannotOverride(MethodSymbol m, MethodSymbol other) {
   1.100          String key;
   1.101          if ((other.owner.flags() & INTERFACE) == 0)
   1.102              key = "cant.override";
   1.103 @@ -1036,7 +1038,7 @@
   1.104              key = "cant.implement";
   1.105          else
   1.106              key = "clashes.with";
   1.107 -        return JCDiagnostic.fragment(key, m, m.location(), other, other.location());
   1.108 +        return diags.fragment(key, m, m.location(), other, other.location());
   1.109      }
   1.110  
   1.111      /** A customized "override" warning message.
   1.112 @@ -1044,7 +1046,7 @@
   1.113       *  @param other  The overridden method.
   1.114       *  @return       An internationalized string.
   1.115       */
   1.116 -    static Object uncheckedOverrides(MethodSymbol m, MethodSymbol other) {
   1.117 +    Object uncheckedOverrides(MethodSymbol m, MethodSymbol other) {
   1.118          String key;
   1.119          if ((other.owner.flags() & INTERFACE) == 0)
   1.120              key = "unchecked.override";
   1.121 @@ -1052,7 +1054,7 @@
   1.122              key = "unchecked.implement";
   1.123          else
   1.124              key = "unchecked.clash.with";
   1.125 -        return JCDiagnostic.fragment(key, m, m.location(), other, other.location());
   1.126 +        return diags.fragment(key, m, m.location(), other, other.location());
   1.127      }
   1.128  
   1.129      /** A customized "override" warning message.
   1.130 @@ -1060,7 +1062,7 @@
   1.131       *  @param other  The overridden method.
   1.132       *  @return       An internationalized string.
   1.133       */
   1.134 -    static Object varargsOverrides(MethodSymbol m, MethodSymbol other) {
   1.135 +    Object varargsOverrides(MethodSymbol m, MethodSymbol other) {
   1.136          String key;
   1.137          if ((other.owner.flags() & INTERFACE) == 0)
   1.138              key = "varargs.override";
   1.139 @@ -1068,7 +1070,7 @@
   1.140              key = "varargs.implement";
   1.141          else
   1.142              key = "varargs.clash.with";
   1.143 -        return JCDiagnostic.fragment(key, m, m.location(), other, other.location());
   1.144 +        return diags.fragment(key, m, m.location(), other, other.location());
   1.145      }
   1.146  
   1.147      /** Check that this method conforms with overridden method 'other'.
   1.148 @@ -1157,7 +1159,7 @@
   1.149                  // allow limited interoperability with covariant returns
   1.150              } else {
   1.151                  typeError(TreeInfo.diagnosticPositionFor(m, tree),
   1.152 -                          JCDiagnostic.fragment("override.incompatible.ret",
   1.153 +                          diags.fragment("override.incompatible.ret",
   1.154                                           cannotOverride(m, other)),
   1.155                            mtres, otres);
   1.156                  return;
   1.157 @@ -1165,7 +1167,7 @@
   1.158          } else if (overrideWarner.warned) {
   1.159              warnUnchecked(TreeInfo.diagnosticPositionFor(m, tree),
   1.160                            "prob.found.req",
   1.161 -                          JCDiagnostic.fragment("override.unchecked.ret",
   1.162 +                          diags.fragment("override.unchecked.ret",
   1.163                                                uncheckedOverrides(m, other)),
   1.164                            mtres, otres);
   1.165          }
   1.166 @@ -2170,7 +2172,7 @@
   1.167              boolean warned = this.warned;
   1.168              super.warnUnchecked();
   1.169              if (warned) return; // suppress redundant diagnostics
   1.170 -            Object problem = JCDiagnostic.fragment(key);
   1.171 +            Object problem = diags.fragment(key);
   1.172              Check.this.warnUnchecked(pos(), "prob.found.req", problem, found, expected);
   1.173          }
   1.174      }

mercurial