Coverage Report - com.sun.tools.javafx.comp.JavafxResolve
 
Classes in this File Line Coverage Branch Coverage Complexity
JavafxResolve
70%
456/652
57%
484/855
0
JavafxResolve$1
100%
1/1
N/A
0
JavafxResolve$AccessError
33%
6/18
6%
1/18
0
JavafxResolve$AmbiguityError
86%
12/14
50%
3/6
0
JavafxResolve$ResolveError
85%
39/46
57%
24/42
0
JavafxResolve$StaticError
100%
6/6
25%
1/4
0
 
 1  
 /*
 2  
  * Copyright 1999-2007 Sun Microsystems, Inc.  All Rights Reserved.
 3  
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 4  
  *
 5  
  * This code is free software; you can redistribute it and/or modify it
 6  
  * under the terms of the GNU General Public License version 2 only, as
 7  
  * published by the Free Software Foundation.  Sun designates this
 8  
  * particular file as subject to the "Classpath" exception as provided
 9  
  * by Sun in the LICENSE file that accompanied this code.
 10  
  *
 11  
  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  
  * version 2 for more details (a copy is included in the LICENSE file that
 15  
  * accompanied this code).
 16  
  *
 17  
  * You should have received a copy of the GNU General Public License version
 18  
  * 2 along with this work; if not, write to the Free Software Foundation,
 19  
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  
  *
 21  
  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 22  
  * CA 95054 USA or visit www.sun.com if you need additional information or
 23  
  * have any questions.
 24  
  */
 25  
 
 26  
 package com.sun.tools.javafx.comp;
 27  
 
 28  
 import com.sun.tools.javac.comp.*;
 29  
 import com.sun.tools.javac.util.*;
 30  
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 31  
 import com.sun.tools.javac.code.*;
 32  
 import com.sun.tools.javac.jvm.*;
 33  
 import com.sun.tools.javac.tree.*;
 34  
 
 35  
 import com.sun.tools.javac.code.Type.*;
 36  
 import com.sun.tools.javac.code.Symbol.*;
 37  
 
 38  
 import static com.sun.tools.javac.code.Flags.*;
 39  
 import static com.sun.tools.javac.code.Kinds.*;
 40  
 import static com.sun.tools.javac.code.TypeTags.*;
 41  
 import javax.lang.model.element.ElementVisitor;
 42  
 
 43  
 import com.sun.tools.javafx.code.*;
 44  
 import com.sun.tools.javafx.tree.*;
 45  
 import com.sun.tools.javafx.util.MsgSym;
 46  
 import java.util.HashSet;
 47  
 import java.util.Set;
 48  
 
 49  
 /** Helper class for name resolution, used mostly by the attribution phase.
 50  
  *
 51  
  *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
 52  
  *  you write code that depends on this, you do so at your own risk.
 53  
  *  This code and its internal interfaces are subject to change or
 54  
  *  deletion without notice.</b>
 55  
  */
 56  33
 public class JavafxResolve {
 57  12
     protected static final Context.Key<JavafxResolve> javafxResolveKey =
 58  
         new Context.Key<JavafxResolve>();
 59  
 
 60  
     Name.Table names;
 61  
     Log log;
 62  
     Symtab syms;
 63  
     JavafxCheck chk;
 64  
     Infer infer;
 65  
     JavafxClassReader reader;
 66  
     TreeInfo treeinfo;
 67  
     JavafxTypes types;
 68  
     public final boolean boxingEnabled; // = source.allowBoxing();
 69  
     public final boolean varargsEnabled; // = source.allowVarargs();
 70  
     private final boolean debugResolve;
 71  
 
 72  
     public static JavafxResolve instance(Context context) {
 73  2394
         JavafxResolve instance = context.get(javafxResolveKey);
 74  2394
         if (instance == null)
 75  399
             instance = new JavafxResolve(context);
 76  2394
         return instance;
 77  
     }
 78  
 
 79  399
     protected JavafxResolve(Context context) {
 80  399
         context.put(javafxResolveKey, this);
 81  399
         syms = Symtab.instance(context);
 82  
 
 83  399
         varNotFound = new
 84  
             ResolveError(ABSENT_VAR, syms.errSymbol, "variable not found");
 85  399
         wrongMethod = new
 86  
             ResolveError(WRONG_MTH, syms.errSymbol, "method not found");
 87  399
         wrongMethods = new
 88  
             ResolveError(WRONG_MTHS, syms.errSymbol, "wrong methods");
 89  399
         methodNotFound = new
 90  
             ResolveError(ABSENT_MTH, syms.errSymbol, "method not found");
 91  399
         typeNotFound = new
 92  
             ResolveError(ABSENT_TYP, syms.errSymbol, "type not found");
 93  
 
 94  399
         names = Name.Table.instance(context);
 95  399
         log = Log.instance(context);
 96  399
         chk = (JavafxCheck)JavafxCheck.instance(context);
 97  399
         infer = Infer.instance(context);
 98  399
         reader = JavafxClassReader.instance(context);
 99  399
         treeinfo = TreeInfo.instance(context);
 100  399
         types = JavafxTypes.instance(context);
 101  399
         Source source = Source.instance(context);
 102  399
         boxingEnabled = source.allowBoxing();
 103  399
         varargsEnabled = source.allowVarargs();
 104  399
         Options options = Options.instance(context);
 105  399
         debugResolve = options.get("debugresolve") != null;
 106  399
     }
 107  
 
 108  
     /** error symbols, which are returned when resolution fails
 109  
      */
 110  
     final ResolveError varNotFound;
 111  
     final ResolveError wrongMethod;
 112  
     final ResolveError wrongMethods;
 113  
     final ResolveError methodNotFound;
 114  
     final ResolveError typeNotFound;
 115  
 
 116  
 /* ************************************************************************
 117  
  * Identifier resolution
 118  
  *************************************************************************/
 119  
 
 120  
     /** An environment is "static" if its static level is greater than
 121  
      *  the one of its outer environment
 122  
      */
 123  
 // JavaFX change
 124  
     public
 125  
 // JavaFX change
 126  
     static boolean isStatic(JavafxEnv<JavafxAttrContext> env) {
 127  27662
         return env.info.staticLevel > env.outer.info.staticLevel;
 128  
     }
 129  
 
 130  
     /** An environment is an "initializer" if it is a constructor or
 131  
      *  an instance initializer.
 132  
      */
 133  
     static boolean isInitializer(JavafxEnv<JavafxAttrContext> env) {
 134  0
         Symbol owner = env.info.scope.owner;
 135  0
         return owner.isConstructor() ||
 136  
             owner.owner.kind == TYP &&
 137  
             (owner.kind == VAR ||
 138  
              owner.kind == MTH && (owner.flags() & BLOCK) != 0) &&
 139  
             (owner.flags() & STATIC) == 0;
 140  
     }
 141  
 
 142  
     /** Is class accessible in given evironment?
 143  
      *  @param env    The current environment.
 144  
      *  @param c      The class whose accessibility is checked.
 145  
      */
 146  
     public boolean isAccessible(JavafxEnv<JavafxAttrContext> env, TypeSymbol c) {
 147  40092
         switch ((short)(c.flags() & AccessFlags)) {
 148  
         case PRIVATE:
 149  0
             return
 150  
                 env.enclClass.sym.outermostClass() ==
 151  
                 c.owner.outermostClass();
 152  
         case 0:
 153  2888
             return
 154  
                 env.toplevel.packge == c.owner // fast special case
 155  
                 ||
 156  
                 env.toplevel.packge == c.packge()
 157  
                 ||
 158  
                 // Hack: this case is added since synthesized default constructors
 159  
                 // of anonymous classes should be allowed to access
 160  
                 // classes which would be inaccessible otherwise.
 161  
                 env.enclMethod != null &&
 162  
                 (env.enclMethod.mods.flags & ANONCONSTR) != 0;
 163  
         default: // error recovery
 164  
         case PUBLIC:
 165  37175
             return true;
 166  
         case PROTECTED:
 167  29
             return
 168  
                 env.toplevel.packge == c.owner // fast special case
 169  
                 ||
 170  
                 env.toplevel.packge == c.packge()
 171  
                 ||
 172  
                 isInnerSubClass(env.enclClass.sym, c.owner);
 173  
         }
 174  
     }
 175  
     //where
 176  
         /** Is given class a subclass of given base class, or an inner class
 177  
          *  of a subclass?
 178  
          *  Return null if no such class exists.
 179  
          *  @param c     The class which is the subclass or is contained in it.
 180  
          *  @param base  The base class
 181  
          */
 182  
         private boolean isInnerSubClass(ClassSymbol c, Symbol base) {
 183  0
             while (c != null && !c.isSubClass(base, types)) {
 184  0
                 c = c.owner.enclClass();
 185  
             }
 186  0
             return c != null;
 187  
         }
 188  
 
 189  
     boolean isAccessible(JavafxEnv<JavafxAttrContext> env, Type t) {
 190  36620
         return (t.tag == ARRAY)
 191  
             ? isAccessible(env, types.elemtype(t))
 192  
             : isAccessible(env, t.tsym);
 193  
     }
 194  
 
 195  
     /** Is symbol accessible as a member of given type in given evironment?
 196  
      *  @param env    The current environment.
 197  
      *  @param site   The type of which the tested symbol is regarded
 198  
      *                as a member.
 199  
      *  @param sym    The symbol.
 200  
      */
 201  
     public boolean isAccessible(JavafxEnv<JavafxAttrContext> env, Type site, Symbol sym) {
 202  38344
         if (sym.name == names.init && sym.owner != site.tsym) return false;
 203  
         ClassSymbol sub;
 204  38242
         switch ((short)(sym.flags() & AccessFlags)) {
 205  
         case PRIVATE:
 206  34
             return
 207  
                 (env.enclClass.sym == sym.owner // fast special case
 208  
                  ||
 209  
                  env.enclClass.sym.outermostClass() ==
 210  
                  sym.owner.outermostClass())
 211  
                 &&
 212  
                 isInheritedIn(sym, site.tsym, types);
 213  
         case 0:
 214  25523
             return
 215  
                 (env.toplevel.packge == sym.owner.owner // fast special case
 216  
                  ||
 217  
                  env.toplevel.packge == sym.packge())
 218  
                 &&
 219  
                 isAccessible(env, site)
 220  
                 &&
 221  
                 isInheritedIn(sym, site.tsym, types);
 222  
         case PROTECTED:
 223  10
             return
 224  
                 (env.toplevel.packge == sym.owner.owner // fast special case
 225  
                  ||
 226  
                  env.toplevel.packge == sym.packge()
 227  
                  ||
 228  
                  isProtectedAccessible(sym, env.enclClass.sym, site)
 229  
                  ||
 230  
                  // OK to select instance method or field from 'super' or type name
 231  
                  // (but type names should be disallowed elsewhere!)
 232  
                  env.info.selectSuper && (sym.flags() & STATIC) == 0 && sym.kind != TYP)
 233  
                 &&
 234  
                 isAccessible(env, site)
 235  
                 &&
 236  
                 // `sym' is accessible only if not overridden by
 237  
                 // another symbol which is a member of `site'
 238  
                 // (because, if it is overridden, `sym' is not strictly
 239  
                 // speaking a member of `site'.)
 240  
                 (sym.kind != MTH || sym.isConstructor() ||
 241  
                  ((MethodSymbol)sym).implementation(site.tsym, types, true) == sym);
 242  
         default: // this case includes erroneous combinations as well
 243  12675
             return isAccessible(env, site);
 244  
         }
 245  
     }
 246  
     //where
 247  
         /** Is given protected symbol accessible if it is selected from given site
 248  
          *  and the selection takes place in given class?
 249  
          *  @param sym     The symbol with protected access
 250  
          *  @param c       The class where the access takes place
 251  
          *  @site          The type of the qualifier
 252  
          */
 253  
         private
 254  
         boolean isProtectedAccessible(Symbol sym, ClassSymbol c, Type site) {
 255  3
             while (c != null &&
 256  
                    !(c.isSubClass(sym.owner, types) &&
 257  
                      (c.flags() & INTERFACE) == 0 &&
 258  
                      // In JLS 2e 6.6.2.1, the subclass restriction applies
 259  
                      // only to instance fields and methods -- types are excluded
 260  
                      // regardless of whether they are declared 'static' or not.
 261  
                      ((sym.flags() & STATIC) != 0 || sym.kind == TYP || site.tsym.isSubClass(c, types))))
 262  2
                 c = c.owner.enclClass();
 263  1
             return c != null;
 264  
         }
 265  
 
 266  
     /** Try to instantiate the type of a method so that it fits
 267  
      *  given type arguments and argument types. If succesful, return
 268  
      *  the method's instantiated type, else return null.
 269  
      *  The instantiation will take into account an additional leading
 270  
      *  formal parameter if the method is an instance method seen as a member
 271  
      *  of un underdetermined site In this case, we treat site as an additional
 272  
      *  parameter and the parameters of the class containing the method as
 273  
      *  additional type variables that get instantiated.
 274  
      *
 275  
      *  @param env         The current environment
 276  
      *  @param m           The method symbol.
 277  
      *  @param mt          The expected type.
 278  
      *  @param argtypes    The invocation's given value arguments.
 279  
      *  @param typeargtypes    The invocation's given type arguments.
 280  
      *  @param allowBoxing Allow boxing conversions of arguments.
 281  
      *  @param useVarargs Box trailing arguments into an array for varargs.
 282  
      */
 283  
     Type rawInstantiate(JavafxEnv<JavafxAttrContext> env,
 284  
                         Symbol m,
 285  
                         Type mt,
 286  
                         List<Type> argtypes,
 287  
                         List<Type> typeargtypes,
 288  
                         boolean allowBoxing,
 289  
                         boolean useVarargs,
 290  
                         Warner warn)
 291  
         throws Infer.NoInstanceException {
 292  32929
         if (useVarargs && (m.flags() & VARARGS) == 0) return null;
 293  32926
         m.complete();
 294  
 
 295  
         // tvars is the list of formal type variables for which type arguments
 296  
         // need to inferred.
 297  32926
         List<Type> tvars = env.info.tvars;
 298  32926
         if (typeargtypes == null) typeargtypes = List.nil();
 299  32926
         if (mt.tag != FORALL && typeargtypes.nonEmpty()) {
 300  
             // This is not a polymorphic method, but typeargs are supplied
 301  
             // which is fine, see JLS3 15.12.2.1
 302  32926
         } else if (mt.tag == FORALL && typeargtypes.nonEmpty()) {
 303  0
             ForAll pmt = (ForAll) mt;
 304  0
             if (typeargtypes.length() != pmt.tvars.length())
 305  0
                 return null;
 306  
             // Check type arguments are within bounds
 307  0
             List<Type> formals = pmt.tvars;
 308  0
             List<Type> actuals = typeargtypes;
 309  0
             while (formals.nonEmpty() && actuals.nonEmpty()) {
 310  0
                 List<Type> bounds = types.subst(types.getBounds((TypeVar)formals.head),
 311  
                                                 pmt.tvars, typeargtypes);
 312  0
                 for (; bounds.nonEmpty(); bounds = bounds.tail)
 313  0
                     if (!types.isSubtypeUnchecked(actuals.head, bounds.head, warn))
 314  0
                         return null;
 315  0
                 formals = formals.tail;
 316  0
                 actuals = actuals.tail;
 317  0
             }
 318  0
             mt = types.subst(pmt.qtype, pmt.tvars, typeargtypes);
 319  0
         } else if (mt.tag == FORALL) {
 320  66
             ForAll pmt = (ForAll) mt;
 321  66
             List<Type> tvars1 = types.newInstances(pmt.tvars);
 322  66
             tvars = tvars.appendList(tvars1);
 323  66
             mt = types.subst(pmt.qtype, pmt.tvars, tvars1);
 324  
         }
 325  
 
 326  
         // find out whether we need to go the slow route via infer
 327  32926
         boolean instNeeded = tvars.tail != null/*inlined: tvars.nonEmpty()*/;
 328  32926
         for (List<Type> l = argtypes;
 329  73818
              l.tail != null/*inlined: l.nonEmpty()*/ && !instNeeded;
 330  40892
              l = l.tail) {
 331  40892
             if (l.head.tag == FORALL) instNeeded = true;
 332  
         }
 333  
 
 334  32926
         if (instNeeded)
 335  66
             return
 336  
             infer.instantiateMethod(tvars,
 337  
                                     (MethodType)mt,
 338  
                                     argtypes,
 339  
                                     allowBoxing,
 340  
                                     useVarargs,
 341  
                                     warn);
 342  32860
         return
 343  
             argumentsAcceptable(argtypes, mt.getParameterTypes(),
 344  
                                 allowBoxing, useVarargs, warn)
 345  
             ? mt
 346  
             : null;
 347  
     }
 348  
 
 349  
     /** Same but returns null instead throwing a NoInstanceException
 350  
      */
 351  
     Type instantiate(JavafxEnv<JavafxAttrContext> env,
 352  
                      Type site,
 353  
                      Symbol m,
 354  
                      List<Type> argtypes,
 355  
                      List<Type> typeargtypes,
 356  
                      boolean allowBoxing,
 357  
                      boolean useVarargs,
 358  
                      Warner warn) {
 359  
         try {
 360  6869
             return rawInstantiate(env, m, types.memberType(site, m), argtypes, typeargtypes,
 361  
                                   allowBoxing, useVarargs, warn);
 362  2
         } catch (Infer.NoInstanceException ex) {
 363  2
             return null;
 364  
         }
 365  
     }
 366  
 
 367  
     /** Check if a parameter list accepts a list of args.
 368  
      */
 369  
     boolean argumentsAcceptable(List<Type> argtypes,
 370  
                                 List<Type> formals,
 371  
                                 boolean allowBoxing,
 372  
                                 boolean useVarargs,
 373  
                                 Warner warn) {
 374  32888
         Type varargsFormal = useVarargs ? formals.last() : null;
 375  48425
         while (argtypes.nonEmpty() && formals.head != varargsFormal) {
 376  34073
             boolean works = allowBoxing
 377  
                 ? types.isConvertible(argtypes.head, formals.head, warn)
 378  
                 : types.isSubtypeUnchecked(argtypes.head, formals.head, warn);
 379  34073
             if (!works) return false;
 380  15537
             argtypes = argtypes.tail;
 381  15537
             formals = formals.tail;
 382  15537
         }
 383  14352
         if (formals.head != varargsFormal) return false; // not enough args
 384  13416
         if (!useVarargs)
 385  13414
             return argtypes.isEmpty();
 386  2
         Type elt = types.elemtype(varargsFormal);
 387  10
         while (argtypes.nonEmpty()) {
 388  8
             if (!types.isConvertible(argtypes.head, elt, warn))
 389  0
                 return false;
 390  8
             argtypes = argtypes.tail;
 391  
         }
 392  2
         return true;
 393  
     }
 394  
 
 395  
 /* ***************************************************************************
 396  
  *  Symbol lookup
 397  
  *  the following naming conventions for arguments are used
 398  
  *
 399  
  *       env      is the environment where the symbol was mentioned
 400  
  *       site     is the type of which the symbol is a member
 401  
  *       name     is the symbol's name
 402  
  *                if no arguments are given
 403  
  *       argtypes are the value arguments, if we search for a method
 404  
  *
 405  
  *  If no symbol was found, a ResolveError detailing the problem is returned.
 406  
  ****************************************************************************/
 407  
 
 408  
     /** Find field. Synthetic fields are always skipped.
 409  
      *  @param env     The current environment.
 410  
      *  @param site    The original type from where the selection takes place.
 411  
      *  @param name    The name of the field.
 412  
      *  @param c       The class to search for the field. This is always
 413  
      *                 a superclass or implemented interface of site's class.
 414  
      */
 415  
 // Javafx change
 416  
     public
 417  
 // javafx change 
 418  
     Symbol findField(JavafxEnv<JavafxAttrContext> env,
 419  
                      Type site,
 420  
                      Name name,
 421  
                      TypeSymbol c) {
 422  33766
         Symbol bestSoFar = varNotFound;
 423  
         Symbol sym;
 424  33766
         Scope.Entry e = c.members().lookup(name);
 425  38428
         while (e.scope != null) {
 426  4662
             if ((e.sym.kind & (VAR|MTH)) != 0 && (e.sym.flags_field & SYNTHETIC) == 0) {
 427  4662
                 sym = isAccessible(env, site, e.sym)
 428  
                     ? e.sym : new AccessError(env, site, e.sym);
 429  4662
                 if (bestSoFar.kind < AMBIGUOUS && sym.kind < AMBIGUOUS &&
 430  
                     sym.owner != bestSoFar.owner)
 431  0
                     bestSoFar = new AmbiguityError(bestSoFar, sym);
 432  4662
                 else if (sym.kind < bestSoFar.kind)
 433  4662
                     bestSoFar = sym;
 434  
             }
 435  4662
             e = e.next();
 436  
         }
 437  33766
         if (bestSoFar != varNotFound)
 438  4662
             return bestSoFar;
 439  29104
         Type st = types.supertype(c.type);
 440  29104
         if (st != null && st.tag == CLASS) {
 441  15926
             sym = findField(env, site, name, st.tsym);
 442  15926
             if (sym.kind < bestSoFar.kind) bestSoFar = sym;
 443  
         }
 444  
 
 445  
         // We failed to find the field in the single Java class supertype of the 
 446  
         // Javafx class.
 447  
         // Now try to find the filed in all of the Javafx supertypes.
 448  29104
         if (bestSoFar.kind > AMBIGUOUS && c instanceof JavafxClassSymbol) {
 449  29104
             List<Type> supertypes = ((JavafxClassSymbol)c).getSuperTypes();
 450  29104
             for (Type tp : supertypes) {
 451  4968
                 if (tp != null && tp.tag == CLASS) {
 452  4968
                     sym = findField(env, site, name, tp.tsym);
 453  4968
                     if (sym.kind < bestSoFar.kind) bestSoFar = sym;
 454  4968
                     if (bestSoFar.kind < AMBIGUOUS) {
 455  59
                         break;
 456  
                     }
 457  
                 }
 458  
             }
 459  
         }
 460  
 
 461  29104
         for (List<Type> l = types.interfaces(c.type);
 462  34225
              bestSoFar.kind != AMBIGUOUS && l.nonEmpty();
 463  5121
              l = l.tail) {
 464  5121
             sym = findField(env, site, name, l.head.tsym);
 465  5121
             if (bestSoFar.kind < AMBIGUOUS && sym.kind < AMBIGUOUS &&
 466  
                 sym.owner != bestSoFar.owner)
 467  0
                 bestSoFar = new AmbiguityError(bestSoFar, sym);
 468  5121
             else if (sym.kind < bestSoFar.kind)
 469  0
                 bestSoFar = sym;
 470  
         }
 471  29104
         return bestSoFar;
 472  
     }
 473  
 
 474  
     /** Resolve a field identifier, throw a fatal error if not found.
 475  
      *  @param pos       The position to use for error reporting.
 476  
      *  @param env       The environment current at the method invocation.
 477  
      *  @param site      The type of the qualifying expression, in which
 478  
      *                   identifier is searched.
 479  
      *  @param name      The identifier's name.
 480  
      */
 481  
     public VarSymbol resolveInternalField(DiagnosticPosition pos, JavafxEnv<JavafxAttrContext> env,
 482  
                                           Type site, Name name) {
 483  0
         Symbol sym = findField(env, site, name, site.tsym);
 484  0
         if (sym.kind == VAR) return (VarSymbol)sym;
 485  0
         else throw new FatalError(
 486  
                  JCDiagnostic.fragment(MsgSym.MESSAGE_FATAL_ERR_CANNOT_LOCATE_FIELD,
 487  
                                 name));
 488  
     }
 489  
 
 490  
     /** Find unqualified variable or field with given name.
 491  
      *  Synthetic fields always skipped.
 492  
      *  @param env     The current environment.
 493  
      *  @param name    The name of the variable or field.
 494  
      */
 495  
     Symbol findVar(JavafxEnv<JavafxAttrContext> env, Name name, int kind, Type expected) {
 496  9873
         Symbol bestSoFar = varNotFound;
 497  
         Symbol sym;
 498  9873
         JavafxEnv<JavafxAttrContext> env1 = env;
 499  9873
         boolean staticOnly = false;
 500  9873
         boolean innerAccess = false;
 501  9873
         Type mtype = expected;
 502  9873
         if (mtype instanceof FunctionType)
 503  10
             mtype = mtype.asMethodType();
 504  9873
         boolean checkArgs = mtype instanceof MethodType || mtype instanceof ForAll;
 505  
 
 506  29255
         while (env1 != null) {
 507  27199
             Scope sc = env1.info.scope;
 508  
             Type envClass;
 509  27199
             if (env1.tree instanceof JFXClassDeclaration) {
 510  4814
                 JFXClassDeclaration cdecl = (JFXClassDeclaration) env1.tree;
 511  4814
                 if (cdecl.runMethod != null &&
 512  
                         name != names._this && name != names._super) {
 513  3851
                     envClass = null;
 514  3851
                     sc = cdecl.runBodyScope;
 515  3851
                     innerAccess = true;
 516  
                 }
 517  4814
                 envClass = cdecl.sym.type;
 518  4814
             }
 519  
             else
 520  22385
                 envClass = null;
 521  27199
             if (envClass != null) {
 522  4814
                 sym = findMethod(env1, envClass, name,
 523  
                         expected,
 524  
                         true, false, false);
 525  
 
 526  4814
                 if (sym.exists()) {
 527  2360
                     if (staticOnly) {
 528  
                         // Note: can't call isStatic with null owner
 529  475
                         if (sym.owner != null) {
 530  473
                             if (!sym.isStatic()) {
 531  1
                                 return new StaticError(sym);
 532  
                             }
 533  
                         }
 534  
                     }
 535  2359
                     return sym;
 536  
                 }
 537  
             }
 538  24839
             if (sc != null) {
 539  
                 
 540  26057
                 for (Scope.Entry e = sc.lookup(name); e.scope != null; e = e.next()) {
 541  6982
                     if ((e.sym.flags_field & SYNTHETIC) != 0)
 542  0
                         continue;
 543  6982
                     if ((e.sym.kind & (MTH|VAR)) != 0) {
 544  5457
                         if (innerAccess)
 545  132
                             e.sym.flags_field |= JavafxFlags.INNER_ACCESS;
 546  5457
                         if (checkArgs) {
 547  29
                             Type mt = e.sym.type;
 548  29
                             if (mt instanceof FunctionType)
 549  28
                                 mt = mt.asMethodType();
 550  
                             // Better to use selectBest, but that requires some
 551  
                             // changes.  FIXME
 552  29
                             if (! (mt instanceof MethodType) ||
 553  
                                     ! argumentsAcceptable(mtype.getParameterTypes(), mt.getParameterTypes(),
 554  
                                     true, false, Warner.noWarnings))
 555  1
                                 return wrongMethod.setWrongSym(e.sym);
 556  
                         }
 557  5456
                         return e.sym;
 558  
                     }
 559  
                 }
 560  
             }
 561  
 
 562  19382
             if (env1.tree instanceof JFXFunctionDefinition)
 563  4269
                 innerAccess = true;
 564  19382
             if (env1.outer != null && isStatic(env1)) staticOnly = true;
 565  19382
             env1 = env1.outer;
 566  19382
         }
 567  
 
 568  2056
         Scope.Entry e = env.toplevel.namedImportScope.lookup(name);
 569  5106
         for (; e.scope != null; e = e.next()) {
 570  1525
             sym = e.sym;
 571  1525
             Type origin = e.getOrigin().owner.type;
 572  1525
             if (sym.kind == VAR) {
 573  0
                 if (e.sym.owner.type != origin)
 574  0
                     sym = sym.clone(e.getOrigin().owner);
 575  0
                 return isAccessible(env, origin, sym)
 576  
                     ? sym : new AccessError(env, origin, sym);
 577  
             }
 578  
         }
 579  
 
 580  2056
         Symbol origin = null;
 581  2056
         e = env.toplevel.starImportScope.lookup(name);
 582  2562
         for (; e.scope != null; e = e.next()) {
 583  253
             sym = e.sym;
 584  253
             if (sym.kind != VAR)
 585  253
                 continue;
 586  
             // invariant: sym.kind == VAR
 587  0
             if (bestSoFar.kind < AMBIGUOUS && sym.owner != bestSoFar.owner)
 588  0
                 return new AmbiguityError(bestSoFar, sym);
 589  0
             else if (bestSoFar.kind >= VAR) {
 590  0
                 origin = e.getOrigin().owner;
 591  0
                 bestSoFar = isAccessible(env, origin.type, sym)
 592  
                     ? sym : new AccessError(env, origin.type, sym);
 593  
             }
 594  
         }
 595  
         
 596  2056
         if (name == names.fromString("__DIR__") || name == names.fromString("__FILE__")) {
 597  0
             Type type = reader.enterClass(names.fromString("java.net.URL")).type;
 598  0
             return new VarSymbol(Flags.PUBLIC, name, type, env.enclClass.sym);
 599  
         }
 600  
         
 601  2056
         if (bestSoFar.kind == VAR && bestSoFar.owner.type != origin.type)
 602  0
             return bestSoFar.clone(origin);
 603  
         else
 604  2056
             return bestSoFar;
 605  
     }
 606  
 
 607  399
     Warner noteWarner = new Warner();
 608  
 
 609  
     /** Select the best method for a call site among two choices.
 610  
      *  @param env              The current environment.
 611  
      *  @param site             The original type from where the
 612  
      *                          selection takes place.
 613  
      *  @param argtypes         The invocation's value arguments,
 614  
      *  @param typeargtypes     The invocation's type arguments,
 615  
      *  @param sym              Proposed new best match.
 616  
      *  @param bestSoFar        Previously found best match.
 617  
      *  @param allowBoxing Allow boxing conversions of arguments.
 618  
      *  @param useVarargs Box trailing arguments into an array for varargs.
 619  
      */
 620  
     Symbol selectBest(JavafxEnv<JavafxAttrContext> env,
 621  
                       Type site,
 622  
                       Type expected,
 623  
                       Symbol sym,
 624  
                       Symbol bestSoFar,
 625  
                       boolean allowBoxing,
 626  
                       boolean useVarargs,
 627  
                       boolean operator) {
 628  26060
         if (sym.kind == ERR) return bestSoFar;
 629  26060
         if (!isInheritedIn(sym, site.tsym, types)) return bestSoFar;
 630  26060
         assert sym.kind < AMBIGUOUS;
 631  26060
         List<Type> argtypes = expected.getParameterTypes();
 632  26060
         List<Type> typeargtypes = expected.getTypeArguments();
 633  
         try {
 634  26060
             if (rawInstantiate(env, sym, types.memberType(site, sym), argtypes, typeargtypes,
 635  
                                allowBoxing, useVarargs, Warner.noWarnings) == null) {
 636  
                 // inapplicable
 637  19127
                 switch (bestSoFar.kind) {
 638  1479
                 case ABSENT_MTH: return wrongMethod.setWrongSym(sym);
 639  1263
                 case WRONG_MTH: return wrongMethods;
 640  16385
                 default: return bestSoFar;
 641  
                 }
 642  
             }
 643  50
         } catch (Infer.NoInstanceException ex) {
 644  50
             switch (bestSoFar.kind) {
 645  
             case ABSENT_MTH:
 646  13
                 return wrongMethod.setWrongSym(sym, ex.getDiagnostic());
 647  
             case WRONG_MTH:
 648  13
                 return wrongMethods;
 649  
             default:
 650  24
                 return bestSoFar;
 651  
             }
 652  6883
         }
 653  6883
         if (!isAccessible(env, site, sym)) {
 654  102
             return (bestSoFar.kind == ABSENT_MTH)
 655  
                 ? new AccessError(env, site, sym)
 656  
                 : bestSoFar;
 657  
         }
 658  6781
         return (bestSoFar.kind > AMBIGUOUS)
 659  
             ? sym
 660  
             : mostSpecific(sym, bestSoFar, env, site,
 661  
                            allowBoxing && operator, useVarargs);
 662  
     }
 663  
 
 664  
     /* Return the most specific of the two methods for a call,
 665  
      *  given that both are accessible and applicable.
 666  
      *  @param m1               A new candidate for most specific.
 667  
      *  @param m2               The previous most specific candidate.
 668  
      *  @param env              The current environment.
 669  
      *  @param site             The original type from where the selection
 670  
      *                          takes place.
 671  
      *  @param allowBoxing Allow boxing conversions of arguments.
 672  
      *  @param useVarargs Box trailing arguments into an array for varargs.
 673  
      */
 674  
     Symbol mostSpecific(Symbol m1,
 675  
                         Symbol m2,
 676  
                         JavafxEnv<JavafxAttrContext> env,
 677  
                         Type site,
 678  
                         boolean allowBoxing,
 679  
                         boolean useVarargs) {
 680  1839
         switch (m2.kind) {
 681  
         case MTH:
 682  1818
             if (m1 == m2) return m1;
 683  1795
             Type mt1 = types.memberType(site, m1);
 684  1795
             noteWarner.unchecked = false;
 685  1795
             boolean m1SignatureMoreSpecific =
 686  
                 (instantiate(env, site, m2, types.lowerBoundArgtypes(mt1), null,
 687  
                              allowBoxing, false, noteWarner) != null ||
 688  
                  useVarargs && instantiate(env, site, m2, types.lowerBoundArgtypes(mt1), null,
 689  
                                            allowBoxing, true, noteWarner) != null) &&
 690  
                 !noteWarner.unchecked;
 691  1795
             Type mt2 = types.memberType(site, m2);
 692  1795
             noteWarner.unchecked = false;
 693  1795
             boolean m2SignatureMoreSpecific =
 694  
                 (instantiate(env, site, m1, types.lowerBoundArgtypes(mt2), null,
 695  
                              allowBoxing, false, noteWarner) != null ||
 696  
                  useVarargs && instantiate(env, site, m1, types.lowerBoundArgtypes(mt2), null,
 697  
                                            allowBoxing, true, noteWarner) != null) &&
 698  
                 !noteWarner.unchecked;
 699  1795
             if (m1SignatureMoreSpecific && m2SignatureMoreSpecific) {
 700  82
                 if (!types.overrideEquivalent(mt1, mt2))
 701  1
                     return new AmbiguityError(m1, m2);
 702  
                 // same signature; select (a) the non-bridge method, or
 703  
                 // (b) the one that overrides the other, or (c) the concrete
 704  
                 // one, or (d) merge both abstract signatures
 705  81
                 if ((m1.flags() & BRIDGE) != (m2.flags() & BRIDGE)) {
 706  0
                     return ((m1.flags() & BRIDGE) != 0) ? m2 : m1;
 707  
                 }
 708  
                 // if one overrides or hides the other, use it
 709  81
                 TypeSymbol m1Owner = (TypeSymbol)m1.owner;
 710  81
                 TypeSymbol m2Owner = (TypeSymbol)m2.owner;
 711  81
                 if (types.asSuper(m1Owner.type, m2Owner) != null &&
 712  
                     ((m1.owner.flags_field & INTERFACE) == 0 ||
 713  
                      (m2.owner.flags_field & INTERFACE) != 0) &&
 714  
                     m1.overrides(m2, m1Owner, types, false))
 715  2
                     return m1;
 716  79
                 if (types.asSuper(m2Owner.type, m1Owner) != null &&
 717  
                     ((m2.owner.flags_field & INTERFACE) == 0 ||
 718  
                      (m1.owner.flags_field & INTERFACE) != 0) &&
 719  
                     m2.overrides(m1, m2Owner, types, false))
 720  79
                     return m2;
 721  0
                 boolean m1Abstract = (m1.flags() & ABSTRACT) != 0;
 722  0
                 boolean m2Abstract = (m2.flags() & ABSTRACT) != 0;
 723  0
                 if (m1Abstract && !m2Abstract) return m2;
 724  0
                 if (m2Abstract && !m1Abstract) return m1;
 725  
                 // both abstract or both concrete
 726  0
                 if (!m1Abstract && !m2Abstract)
 727  0
                     return new AmbiguityError(m1, m2);
 728  
                 // check for same erasure
 729  0
                 if (!types.isSameType(m1.erasure(types), m2.erasure(types)))
 730  0
                     return new AmbiguityError(m1, m2);
 731  
                 // both abstract, neither overridden; merge throws clause and result type
 732  
                 Symbol result;
 733  0
                 Type result2 = mt2.getReturnType();
 734  0
                 if (mt2.tag == FORALL)
 735  0
                     result2 = types.subst(result2, ((ForAll)mt2).tvars, ((ForAll)mt1).tvars);
 736  0
                 if (types.isSubtype(mt1.getReturnType(), result2)) {
 737  0
                     result = m1;
 738  0
                 } else if (types.isSubtype(result2, mt1.getReturnType())) {
 739  0
                     result = m2;
 740  
                 } else {
 741  
                     // Theoretically, this can't happen, but it is possible
 742  
                     // due to error recovery or mixing incompatible class files
 743  0
                     return new AmbiguityError(m1, m2);
 744  
                 }
 745  0
                 result = result.clone(result.owner);
 746  0
                 result.type = (Type)result.type.clone();
 747  0
                 result.type.setThrown(chk.intersect(mt1.getThrownTypes(),
 748  
                                                     mt2.getThrownTypes()));
 749  0
                 return result;
 750  
             }
 751  1713
             if (m1SignatureMoreSpecific) return m1;
 752  153
             if (m2SignatureMoreSpecific) return m2;
 753  18
             return new AmbiguityError(m1, m2);
 754  
         case AMBIGUOUS:
 755  21
             AmbiguityError e = (AmbiguityError)m2;
 756  21
             Symbol err1 = mostSpecific(m1, e.sym1, env, site, allowBoxing, useVarargs);
 757  21
             Symbol err2 = mostSpecific(m1, e.sym2, env, site, allowBoxing, useVarargs);
 758  21
             if (err1 == err2) return err1;
 759  21
             if (err1 == e.sym1 && err2 == e.sym2) return m2;
 760  21
             if (err1 instanceof AmbiguityError &&
 761  
                 err2 instanceof AmbiguityError &&
 762  
                 ((AmbiguityError)err1).sym1 == ((AmbiguityError)err2).sym1)
 763  11
                 return new AmbiguityError(m1, m2);
 764  
             else
 765  10
                 return new AmbiguityError(err1, err2);
 766  
         default:
 767  0
             throw new AssertionError();
 768  
         }
 769  
     }
 770  
 
 771  
     /** Find best qualified method matching given name, type and value
 772  
      *  arguments.
 773  
      *  @param env       The current environment.
 774  
      *  @param site      The original type from where the selection
 775  
      *                   takes place.
 776  
      *  @param name      The method's name.
 777  
      *  @param argtypes  The method's value arguments.
 778  
      *  @param typeargtypes The method's type arguments
 779  
      *  @param allowBoxing Allow boxing conversions of arguments.
 780  
      *  @param useVarargs Box trailing arguments into an array for varargs.
 781  
      */
 782  
 
 783  
     Symbol findMethod(JavafxEnv<JavafxAttrContext> env,
 784  
                       Type site,
 785  
                       Name name,
 786  
                       List<Type> argtypes,
 787  
                       List<Type> typeargtypes,
 788  
                       boolean allowBoxing,
 789  
                       boolean useVarargs,
 790  
                       boolean operator) {
 791  1685
         return findMethod(env,
 792  
                           site,
 793  
                           name,
 794  
                           newMethTemplate(argtypes, typeargtypes),
 795  
                           site.tsym.type,
 796  
                           methodNotFound,
 797  
                           allowBoxing,
 798  
                           useVarargs,
 799  
                           operator);
 800  
     }
 801  
 
 802  
     Symbol findMethod(JavafxEnv<JavafxAttrContext> env,
 803  
                       Type site,
 804  
                       Name name,
 805  
                       Type expected,
 806  
                       boolean allowBoxing,
 807  
                       boolean useVarargs,
 808  
                       boolean operator) {
 809  7330
         return findMethod(env,
 810  
                           site,
 811  
                           name,
 812  
                           expected,
 813  
                           site.tsym.type,
 814  
                           methodNotFound,
 815  
                           allowBoxing,
 816  
                           useVarargs,
 817  
                           operator);
 818  
     }
 819  
     // where
 820  
              private Symbol findMethod(JavafxEnv<JavafxAttrContext> env,
 821  
                               Type site,
 822  
                               Name name,
 823  
                               Type expected,
 824  
                               Type intype,
 825  
                               Symbol bestSoFar,
 826  
                               boolean allowBoxing,
 827  
                               boolean useVarargs,
 828  
                               boolean operator) {
 829  15302
         Type mtype = expected;
 830  15302
         if (mtype instanceof FunctionType)
 831  4
             mtype = mtype.asMethodType();
 832  15302
         boolean checkArgs = mtype instanceof MethodType || mtype instanceof ForAll;
 833  40651
         for (Type ct = intype; ct.tag == CLASS; ct = types.supertype(ct)) {
 834  29619
             ClassSymbol c = (ClassSymbol)ct.tsym;
 835  29619
             for (Scope.Entry e = c.members().lookup(name);
 836  54673
                  e.scope != null;
 837  25054
                  e = e.next()) {
 838  27762
                 if ((e.sym.kind & (VAR|MTH)) == 0 ||
 839  
                         (e.sym.flags_field & SYNTHETIC) != 0)
 840  0
                     continue;
 841  27573
                 if (! checkArgs) {
 842  
                     // No argument list to disambiguate.
 843  1496
                     if (bestSoFar.kind == ABSENT_VAR || bestSoFar.kind == ABSENT_MTH)
 844  1496
                         bestSoFar = e.sym;
 845  
                     else
 846  0
                         bestSoFar = new AmbiguityError(bestSoFar, e.sym);
 847  
                 }
 848  26077
                 else if (e.sym.kind == MTH) {
 849  26060
                     e.sym.complete();
 850  26060
                     bestSoFar = selectBest(env, site, mtype,
 851  
                                            e.sym, bestSoFar,
 852  
                                            allowBoxing,
 853  
                                            useVarargs,
 854  
                                            operator);
 855  26060
                     if (bestSoFar != null && bestSoFar.kind < AMBIGUOUS) {
 856  18994
                         if (isExactMatch(mtype, bestSoFar)) {
 857  2691
                             return bestSoFar;
 858  
                         }
 859  
                     }
 860  
                 }
 861  17
                 else if ((e.sym.kind & (VAR|MTH)) != 0 && bestSoFar == methodNotFound)
 862  17
                     return e.sym;
 863  
             }
 864  26911
             if (! checkArgs &&
 865  
                 bestSoFar.kind != ABSENT_VAR && bestSoFar.kind != ABSENT_MTH) {
 866  1562
                 return bestSoFar;
 867  
             }
 868  25349
             Symbol concrete = methodNotFound;
 869  25349
             if ((bestSoFar.flags() & ABSTRACT) == 0)
 870  25315
                 concrete = bestSoFar;
 871  25349
             for (List<Type> l = types.interfaces(c.type);
 872  31636
                  l.nonEmpty();
 873  6287
                  l = l.tail) {
 874  6287
                 bestSoFar = findMethod(env, site, name, expected,
 875  
                                        l.head, bestSoFar,
 876  
                                        allowBoxing, useVarargs, operator);
 877  
             }
 878  25349
             if (concrete != bestSoFar &&
 879  
                 concrete.kind < ERR  && bestSoFar.kind < ERR &&
 880  
                 types.isSubSignature(concrete.type, bestSoFar.type))
 881  0
                 bestSoFar = concrete;
 882  
         }
 883  
 
 884  
         // We failed to find the field in the single Java class supertype of the 
 885  
         // Javafx class.
 886  
         // Now try to find the filed in all of the Javafx supertypes.
 887  11032
         if (bestSoFar.kind > AMBIGUOUS && intype.tsym instanceof JavafxClassSymbol) {
 888  3271
             List<Type> supertypes = ((JavafxClassSymbol)intype.tsym).getSuperTypes();
 889  3271
             for (Type tp : supertypes) {
 890  2820
                 for (Type ct = tp; ct.tag == CLASS; ct = types.supertype(ct)) {
 891  2086
                     ClassSymbol c = (ClassSymbol)ct.tsym;
 892  2086
                     for (Scope.Entry e = c.members().lookup(name);
 893  2086
                          e.scope != null;
 894  0
                          e = e.next()) {
 895  22
                         if ((e.sym.kind & (VAR|MTH)) == 0 ||
 896  
                                 (e.sym.flags_field & SYNTHETIC) != 0)
 897  0
                             continue;
 898  22
                         if (! checkArgs) {
 899  
                             // No argument list to disambiguate.
 900  0
                             if (bestSoFar.kind == ABSENT_VAR || bestSoFar.kind == ABSENT_MTH)
 901  0
                                 bestSoFar = e.sym;
 902  
                             else
 903  0
                                 bestSoFar = new AmbiguityError(bestSoFar, e.sym);
 904  
                         }
 905  22
                         else if (e.sym.kind == MTH) {
 906  22
                             return e.sym;
 907  
                         }
 908  0
                         else if ((e.sym.kind & (VAR|MTH)) != 0 && bestSoFar == methodNotFound)
 909  0
                             return e.sym;
 910  
                     }
 911  2064
                     if (! checkArgs &&
 912  
                         bestSoFar.kind != ABSENT_VAR && bestSoFar.kind != ABSENT_MTH) {
 913  0
                         return bestSoFar;
 914  
                     }
 915  
                 }
 916  
                 
 917  734
                 if (bestSoFar.kind < AMBIGUOUS) {
 918  0
                     break;
 919  
                 }
 920  
             }
 921  
         }
 922  
 
 923  11010
         return bestSoFar;
 924  
     }
 925  
 
 926  
     private boolean isExactMatch(Type mtype, Symbol bestSoFar) {
 927  18994
         if (bestSoFar.kind == MTH && (bestSoFar.type instanceof MethodType) &&
 928  
                 mtype.tag == TypeTags.METHOD ) {
 929  18973
             List<Type> actuals = ((MethodType)mtype).getParameterTypes();
 930  18973
             List<Type> formals = ((MethodType)bestSoFar.type).getParameterTypes();
 931  18973
             if (actuals != null && formals != null) {
 932  18973
                 if (actuals.size() == formals.size()) {
 933  18972
                     for (Type actual : actuals) {
 934  20134
                         if (actual != formals.head) {
 935  16281
                             return false;
 936  
                         }
 937  
 
 938  3853
                         formals = formals.tail;
 939  
                     }
 940  2691
                     return true;
 941  
                 }
 942  
             }
 943  
         }
 944  
         
 945  22
         return false;
 946  
     }
 947  
 
 948  
     Type newMethTemplate(List<Type> argtypes, List<Type> typeargtypes) {
 949  1732
         MethodType mt = new MethodType(argtypes, null, null, syms.methodClass);
 950  1732
         return (typeargtypes == null) ? mt : (Type)new ForAll(typeargtypes, mt);
 951  
     }
 952  
          
 953  
     /** Load toplevel or member class with given fully qualified name and
 954  
      *  verify that it is accessible.
 955  
      *  @param env       The current environment.
 956  
      *  @param name      The fully qualified name of the class to be loaded.
 957  
      */
 958  
     Symbol loadClass(JavafxEnv<JavafxAttrContext> env, Name name) {
 959  
         try {
 960  5482
             ClassSymbol c = reader.loadClass(name);
 961  3472
             return isAccessible(env, c) ? c : new AccessError(c);
 962  0
         } catch (ClassReader.BadClassFile err) {
 963  0
             throw err;
 964  2010
         } catch (CompletionFailure ex) {
 965  2010
             return typeNotFound;
 966  
         }
 967  
     }
 968  
 
 969  
     /** Find qualified member type.
 970  
      *  @param env       The current environment.
 971  
      *  @param site      The original type from where the selection takes
 972  
      *                   place.
 973  
      *  @param name      The type's name.
 974  
      *  @param c         The class to search for the member type. This is
 975  
      *                   always a superclass or implemented interface of
 976  
      *                   site's class.
 977  
      */
 978  
 // Javafx change
 979  
     public
 980  
 // Javafx change
 981  
     Symbol findMemberType(JavafxEnv<JavafxAttrContext> env,
 982  
                           Type site,
 983  
                           Name name,
 984  
                           TypeSymbol c) {
 985  23222
         Symbol bestSoFar = typeNotFound;
 986  
         Symbol sym;
 987  23222
         Scope.Entry e = c.members().lookup(name);
 988  23222
         while (e.scope != null) {
 989  709
             if (e.sym.kind == TYP) {
 990  709
                 return isAccessible(env, site, e.sym)
 991  
                     ? e.sym
 992  
                     : new AccessError(env, site, e.sym);
 993  
             }
 994  0
             e = e.next();
 995  
         }
 996  22513
         Type st = types.supertype(c.type);
 997  22513
         if (st != null && st.tag == CLASS) {
 998  11946
             sym = findMemberType(env, site, name, st.tsym);
 999  11946
             if (sym.kind < bestSoFar.kind) bestSoFar = sym;
 1000  
         }
 1001  
 
 1002  
         // We failed to find the field in the single Java class supertype of the 
 1003  
         // Javafx class.
 1004  
         // Now try to find the filed in all of the Javafx supertypes.
 1005  22513
         if (bestSoFar.kind > AMBIGUOUS && c instanceof JavafxClassSymbol) {
 1006  22513
             List<Type> supertypes = ((JavafxClassSymbol)c).getSuperTypes();
 1007  22513
             for (Type tp : supertypes) {
 1008  3148
                 if (tp != null && tp.tag == CLASS) {
 1009  3148
                     sym = findField(env, site, name, tp.tsym);
 1010  3148
                     if (sym.kind < bestSoFar.kind) bestSoFar = sym;
 1011  3148
                     if (bestSoFar.kind < AMBIGUOUS) {
 1012  0
                         break;
 1013  
                     }
 1014  
                 }
 1015  
             }
 1016  
         }
 1017  
 
 1018  22513
         for (List<Type> l = types.interfaces(c.type);
 1019  24243
              bestSoFar.kind != AMBIGUOUS && l.nonEmpty();
 1020  1730
              l = l.tail) {
 1021  1730
             sym = findMemberType(env, site, name, l.head.tsym);
 1022  1730
             if (bestSoFar.kind < AMBIGUOUS && sym.kind < AMBIGUOUS &&
 1023  
                 sym.owner != bestSoFar.owner)
 1024  0
                 bestSoFar = new AmbiguityError(bestSoFar, sym);
 1025  1730
             else if (sym.kind < bestSoFar.kind)
 1026  0
                 bestSoFar = sym;
 1027  
         }
 1028  22513
         return bestSoFar;
 1029  
     }
 1030  
 
 1031  
     /** Find a global type in given scope and load corresponding class.
 1032  
      *  @param env       The current environment.
 1033  
      *  @param scope     The scope in which to look for the type.
 1034  
      *  @param name      The type's name.
 1035  
      */
 1036  
     Symbol findGlobalType(JavafxEnv<JavafxAttrContext> env, Scope scope, Name name) {
 1037  4049
         Symbol bestSoFar = typeNotFound;
 1038  6329
         for (Scope.Entry e = scope.lookup(name); e.scope != null; e = e.next()) {
 1039  2280
             Symbol sym = loadClass(env, e.sym.flatName());
 1040  2280
             if (bestSoFar.kind == TYP && sym.kind == TYP &&
 1041  
                 bestSoFar != sym)
 1042  0
                 return new AmbiguityError(bestSoFar, sym);
 1043  2280
             else if (sym.kind < bestSoFar.kind)
 1044  2267
                 bestSoFar = sym;
 1045  
         }
 1046  4049
         return bestSoFar;
 1047  
     }
 1048  
 
 1049  
     /** Find an unqualified type symbol.
 1050  
      *  @param env       The current environment.
 1051  
      *  @param name      The type's name.
 1052  
      */
 1053  
     Symbol findType(JavafxEnv<JavafxAttrContext> env, Name name) {
 1054  3587
         Symbol bestSoFar = typeNotFound;
 1055  
         Symbol sym;
 1056  3587
         boolean staticOnly = false;
 1057  12424
         for (JavafxEnv<JavafxAttrContext> env1 = env; env1.outer != null; env1 = env1.outer) {
 1058  9542
             if (isStatic(env1)) staticOnly = true;
 1059  9542
             for (Scope.Entry e = env1.info.scope.lookup(name);
 1060  9542
                  e.scope != null;
 1061  0
                  e = e.next()) {
 1062  0
                 if (e.sym.kind == TYP) {
 1063  0
                     if (staticOnly &&
 1064  
                         e.sym.type.tag == TYPEVAR &&
 1065  0
                         e.sym.owner.kind == TYP) return new StaticError(e.sym);
 1066  0
                     return e.sym;
 1067  
                 }
 1068  
             }
 1069  
 
 1070  9542
             sym = findMemberType(env1, env1.enclClass.sym.type, name,
 1071  
                                  env1.enclClass.sym);
 1072  9542
             if (staticOnly && sym.kind == TYP &&
 1073  
                 sym.type.tag == CLASS &&
 1074  
                 sym.type.getEnclosingType().tag == CLASS &&
 1075  
                 env1.enclClass.sym.type.isParameterized() &&
 1076  
                 sym.type.getEnclosingType().isParameterized())
 1077  0
                 return new StaticError(sym);
 1078  9542
             else if (sym.exists()) return sym;
 1079  8837
             else if (sym.kind < bestSoFar.kind) bestSoFar = sym;
 1080  
 
 1081  8837
             JFXClassDeclaration encl = env1.baseClause ? (JFXClassDeclaration)env1.tree : env1.enclClass;
 1082  8837
             if ((encl.sym.flags() & STATIC) != 0)
 1083  1267
                 staticOnly = true;
 1084  
         }
 1085  
 
 1086  2882
         if (env.tree.getTag() != JCTree.IMPORT) {
 1087  2473
             sym = findGlobalType(env, env.toplevel.namedImportScope, name);
 1088  2473
             if (sym.exists()) return sym;
 1089  818
             else if (sym.kind < bestSoFar.kind) bestSoFar = sym;
 1090  
 
 1091  818
             sym = findGlobalType(env, env.toplevel.packge.members(), name);
 1092  818
             if (sym.exists()) return sym;
 1093  758
             else if (sym.kind < bestSoFar.kind) bestSoFar = sym;
 1094  
 
 1095  758
             sym = findGlobalType(env, env.toplevel.starImportScope, name);
 1096  758
             if (sym.exists()) return sym;
 1097  206
             else if (sym.kind < bestSoFar.kind) bestSoFar = sym;
 1098  
         }
 1099  
 
 1100  615
         return bestSoFar;
 1101  
     }
 1102  
 
 1103  
     /** Find an unqualified identifier which matches a specified kind set.
 1104  
      *  @param env       The current environment.
 1105  
      *  @param name      The indentifier's name.
 1106  
      *  @param kind      Indicates the possible symbol kinds
 1107  
      *                   (a subset of VAL, TYP, PCK).
 1108  
      */
 1109  
     Symbol findIdent(JavafxEnv<JavafxAttrContext> env, Name name, int kind, Type expected) {
 1110  11416
         Symbol bestSoFar = typeNotFound;
 1111  
         Symbol sym;
 1112  11416
         if ((kind & (VAR|MTH)) != 0) {
 1113  9873
             sym = findVar(env, name, kind, expected);
 1114  9873
             if (sym.exists()) return sym;
 1115  2056
             else if (sym.kind < bestSoFar.kind) bestSoFar = sym;
 1116  
         }
 1117  
 
 1118  3599
         if ((kind & TYP) != 0) {
 1119  3587
             sym = findType(env, name);
 1120  3587
             if (sym.exists()) return sym;
 1121  615
             else if (sym.kind < bestSoFar.kind) bestSoFar = sym;
 1122  
         }
 1123  
 
 1124  627
         if ((kind & PCK) != 0) return reader.enterPackage(name);
 1125  14
         else return bestSoFar;
 1126  
     }
 1127  
 
 1128  
     /** Find an identifier in a package which matches a specified kind set.
 1129  
      *  @param env       The current environment.
 1130  
      *  @param name      The identifier's name.
 1131  
      *  @param kind      Indicates the possible symbol kinds
 1132  
      *                   (a nonempty subset of TYP, PCK).
 1133  
      */
 1134  
     Symbol findIdentInPackage(JavafxEnv<JavafxAttrContext> env, TypeSymbol pck,
 1135  
                               Name name, int kind) {
 1136  3226
         Name fullname = TypeSymbol.formFullName(name, pck);
 1137  3226
         Symbol bestSoFar = typeNotFound;
 1138  3226
         PackageSymbol pack = null;
 1139  3226
         if ((kind & PCK) != 0) {
 1140  2088
             pack = reader.enterPackage(fullname);
 1141  2088
             if (pack.exists()) return pack;
 1142  
         }
 1143  3202
         if ((kind & TYP) != 0) {
 1144  3202
             Symbol sym = loadClass(env, fullname);
 1145  3202
             if (sym.exists()) {
 1146  
                 // don't allow programs to use flatnames
 1147  1192
                 if (name == sym.name) return sym;
 1148  
             }
 1149  2010
             else if (sym.kind < bestSoFar.kind) bestSoFar = sym;
 1150  
         }
 1151  2010
         return (pack != null) ? pack : bestSoFar;
 1152  
     }
 1153  
 
 1154  
     /** Find an identifier among the members of a given type `site'.
 1155  
      *  @param env       The current environment.
 1156  
      *  @param site      The type containing the symbol to be found.
 1157  
      *  @param name      The identifier's name.
 1158  
      *  @param kind      Indicates the possible symbol kinds
 1159  
      *                   (a subset of VAL, TYP).
 1160  
      */
 1161  
     Symbol findIdentInType(JavafxEnv<JavafxAttrContext> env, Type site,
 1162  
                            Name name, int kind) {
 1163  4607
         Symbol bestSoFar = typeNotFound;
 1164  
         Symbol sym;
 1165  4607
         if ((kind & (VAR|MTH)) != 0) {
 1166  4603
             sym = findField(env, site, name, site.tsym);
 1167  4603
             if (sym.exists()) return sym;
 1168  0
             else if (sym.kind < bestSoFar.kind) bestSoFar = sym;
 1169  
         }
 1170  
 
 1171  4
         if ((kind & TYP) != 0) {
 1172  4
             sym = findMemberType(env, site, name, site.tsym);
 1173  4
             if (sym.exists()) return sym;
 1174  0
             else if (sym.kind < bestSoFar.kind) bestSoFar = sym;
 1175  
         }
 1176  0
         return bestSoFar;
 1177  
     }
 1178  
 
 1179  
 /* ***************************************************************************
 1180  
  *  Access checking
 1181  
  *  The following methods convert ResolveErrors to ErrorSymbols, issuing
 1182  
  *  an error message in the process
 1183  
  ****************************************************************************/
 1184  
 
 1185  
     /** If `sym' is a bad symbol: report error and return errSymbol
 1186  
      *  else pass through unchanged,
 1187  
      *  additional arguments duplicate what has been used in trying to find the
 1188  
      *  symbol (--> flyweight pattern). This improves performance since we
 1189  
      *  expect misses to happen frequently.
 1190  
      *
 1191  
      *  @param sym       The symbol that was found, or a ResolveError.
 1192  
      *  @param pos       The position to use for error reporting.
 1193  
      *  @param site      The original type from where the selection took place.
 1194  
      *  @param name      The symbol's name.
 1195  
      *  @param argtypes  The invocation's value arguments,
 1196  
      *                   if we looked for a method.
 1197  
      *  @param typeargtypes  The invocation's type arguments,
 1198  
      *                   if we looked for a method.
 1199  
      */
 1200  
     Symbol access(Symbol sym,
 1201  
                   DiagnosticPosition pos,
 1202  
                   Type site,
 1203  
                   Name name,
 1204  
                   boolean qualified,
 1205  
                   List<Type> argtypes,
 1206  
                   List<Type> typeargtypes) {
 1207  1594
         if (sym.kind >= AMBIGUOUS) {
 1208  
 //          printscopes(site.tsym.members());//DEBUG
 1209  25
             if (!site.isErroneous() &&
 1210  
                 !Type.isErroneous(argtypes) &&
 1211  
                 (typeargtypes==null || !Type.isErroneous(typeargtypes))) {
 1212  24
                 ((ResolveError)sym).report(log, pos, site, name, argtypes, typeargtypes);
 1213  
             }
 1214  
             do {
 1215  25
                 sym = ((ResolveError)sym).sym;
 1216  25
             } while (sym.kind >= AMBIGUOUS);
 1217  25
             if (sym == syms.errSymbol // preserve the symbol name through errors
 1218  
                 || ((sym.kind & ERRONEOUS) == 0 // make sure an error symbol is returned
 1219  
                     && (sym.kind & TYP) != 0))
 1220  22
                 sym = new ErrorType(name, qualified?site.tsym:syms.noSymbol).tsym;
 1221  
         }
 1222  1594
         return sym;
 1223  
     }
 1224  
 
 1225  
     Symbol access(Symbol sym,
 1226  
                   DiagnosticPosition pos,
 1227  
                   Type site,
 1228  
                   Name name,
 1229  
                   boolean qualified,
 1230  
                   Type expected) {
 1231  22
         return access(sym, pos, site, name, qualified, expected.getParameterTypes(), expected.getTypeArguments());
 1232  
     }
 1233  
     /** Same as above, but without type arguments and arguments.
 1234  
      */
 1235  
 // Javafx change
 1236  
     public
 1237  
 // Javafx change
 1238  
     Symbol access(Symbol sym,
 1239  
                   DiagnosticPosition pos,
 1240  
                   Type site,
 1241  
                   Name name,
 1242  
                   boolean qualified) {
 1243  7833
         if (sym.kind >= AMBIGUOUS)
 1244  2
             return access(sym, pos, site, name, qualified, List.<Type>nil(), null);
 1245  
         else
 1246  7831
             return sym;
 1247  
     }
 1248  
 
 1249  
     /** Check that sym is not an abstract method.
 1250  
      */
 1251  
     void checkNonAbstract(DiagnosticPosition pos, Symbol sym) {
 1252  11
         if ((sym.flags() & ABSTRACT) != 0)
 1253  0
             log.error(pos, MsgSym.MESSAGE_ABSTRACT_CANNOT_BE_ACCESSED_DIRECTLY,
 1254  
                       kindName(sym), sym, sym.location());
 1255  11
     }
 1256  
 
 1257  
 /* ***************************************************************************
 1258  
  *  Debugging
 1259  
  ****************************************************************************/
 1260  
 
 1261  
     /** print all scopes starting with scope s and proceeding outwards.
 1262  
      *  used for debugging.
 1263  
      */
 1264  
     public void printscopes(Scope s) {
 1265  0
         while (s != null) {
 1266  0
             if (s.owner != null)
 1267  0
                 System.err.print(s.owner + ": ");
 1268  0
             for (Scope.Entry e = s.elems; e != null; e = e.sibling) {
 1269  0
                 if ((e.sym.flags() & ABSTRACT) != 0)
 1270  0
                     System.err.print("abstract ");
 1271  0
                 System.err.print(e.sym + " ");
 1272  
             }
 1273  0
             System.err.println();
 1274  0
             s = s.next;
 1275  
         }
 1276  0
     }
 1277  
 
 1278  
     void printscopes(JavafxEnv<JavafxAttrContext> env) {
 1279  0
         while (env.outer != null) {
 1280  0
             System.err.println("------------------------------");
 1281  0
             printscopes(env.info.scope);
 1282  0
             env = env.outer;
 1283  
         }
 1284  0
     }
 1285  
 
 1286  
     public void printscopes(Type t) {
 1287  0
         while (t.tag == CLASS) {
 1288  0
             printscopes(t.tsym.members());
 1289  0
             t = types.supertype(t);
 1290  
         }
 1291  0
     }
 1292  
 
 1293  
 /* ***************************************************************************
 1294  
  *  Name resolution
 1295  
  *  Naming conventions are as for symbol lookup
 1296  
  *  Unlike the find... methods these methods will report access errors
 1297  
  ****************************************************************************/
 1298  
 
 1299  
     /** Resolve an unqualified (non-method) identifier.
 1300  
      *  @param pos       The position to use for error reporting.
 1301  
      *  @param env       The environment current at the identifier use.
 1302  
      *  @param name      The identifier's name.
 1303  
      *  @param kind      The set of admissible symbol kinds for the identifier.
 1304  
      *  @param pt        The expected type.
 1305  
      */
 1306  
     Symbol resolveIdent(DiagnosticPosition pos, JavafxEnv<JavafxAttrContext> env,
 1307  
                         Name name, int kind, Type pt) {
 1308  11416
         Symbol sym = findIdent(env, name, kind, pt);
 1309  11416
         if (sym.kind >= AMBIGUOUS)
 1310  18
             return access(sym, pos, env.enclClass.sym.type, name, false, pt);
 1311  
         else
 1312  11398
             return sym;
 1313  
     }
 1314  
 
 1315  
     /** Resolve a qualified method identifier
 1316  
      *  @param pos       The position to use for error reporting.
 1317  
      *  @param env       The environment current at the method invocation.
 1318  
      *  @param site      The type of the qualifying expression, in which
 1319  
      *                   identifier is searched.
 1320  
      *  @param name      The identifier's name.
 1321  
      *  @param argtypes  The types of the invocation's value arguments.
 1322  
      *  @param typeargtypes  The types of the invocation's type arguments.
 1323  
      */
 1324  
     Symbol resolveQualifiedMethod(DiagnosticPosition pos, JavafxEnv<JavafxAttrContext> env,
 1325  
                                   Type site, Name name, Type expected) {
 1326  2489
         Symbol sym = findMethod(env, site, name, expected, false,
 1327  
                                 env.info.varArgs=false, false);
 1328  2489
         if (varargsEnabled && sym.kind >= WRONG_MTHS) {
 1329  23
             sym = findMethod(env, site, name, expected, true,
 1330  
                              false, false);
 1331  23
             if (sym.kind >= WRONG_MTHS)
 1332  4
                 sym = findMethod(env, site, name, expected, true,
 1333  
                                  env.info.varArgs=true, false);
 1334  
         }
 1335  2489
         if (sym.kind >= AMBIGUOUS) {
 1336  4
             sym = access(sym, pos, site, name, true, expected);
 1337  
         }
 1338  2489
         return sym;
 1339  
     }
 1340  
 
 1341  
     /** Resolve a qualified method identifier, throw a fatal error if not
 1342  
      *  found.
 1343  
      *  @param pos       The position to use for error reporting.
 1344  
      *  @param env       The environment current at the method invocation.
 1345  
      *  @param site      The type of the qualifying expression, in which
 1346  
      *                   identifier is searched.
 1347  
      *  @param name      The identifier's name.
 1348  
      *  @param argtypes  The types of the invocation's value arguments.
 1349  
      *  @param typeargtypes  The types of the invocation's type arguments.
 1350  
      */
 1351  
     public MethodSymbol resolveInternalMethod(DiagnosticPosition pos, JavafxEnv<JavafxAttrContext> env,
 1352  
                                         Type site, Name name,
 1353  
                                         List<Type> argtypes,
 1354  
                                         List<Type> typeargtypes) {
 1355  47
         Symbol sym = resolveQualifiedMethod(
 1356  
             pos, env, site, name, newMethTemplate(argtypes, typeargtypes));
 1357  47
         if (sym.kind == MTH) return (MethodSymbol)sym;
 1358  0
         else throw new FatalError(
 1359  
                  JCDiagnostic.fragment(MsgSym.MESSAGE_FATAL_ERR_CANNOT_LOCATE_METH,
 1360  
                                 name));
 1361  
     }
 1362  
 
 1363  
     /** Resolve constructor.
 1364  
      *  @param pos       The position to use for error reporting.
 1365  
      *  @param env       The environment current at the constructor invocation.
 1366  
      *  @param site      The type of class for which a constructor is searched.
 1367  
      *  @param argtypes  The types of the constructor invocation's value
 1368  
      *                   arguments.
 1369  
      *  @param typeargtypes  The types of the constructor invocation's type
 1370  
      *                   arguments.
 1371  
      */
 1372  
     public // Javafx change
 1373  
     Symbol resolveConstructor(DiagnosticPosition pos,
 1374  
                               JavafxEnv<JavafxAttrContext> env,
 1375  
                               Type site,
 1376  
                               List<Type> argtypes,
 1377  
                               List<Type> typeargtypes) {
 1378  83
         Symbol sym = resolveConstructor(pos, env, site, argtypes, typeargtypes, false, env.info.varArgs=false);
 1379  83
         if (varargsEnabled && sym.kind >= WRONG_MTHS) {
 1380  1
             sym = resolveConstructor(pos, env, site, argtypes, typeargtypes, true, false);
 1381  1
             if (sym.kind >= WRONG_MTHS)
 1382  0
                 sym = resolveConstructor(pos, env, site, argtypes, typeargtypes, true, env.info.varArgs=true);
 1383  
         }
 1384  83
         if (sym.kind >= AMBIGUOUS) {
 1385  0
             sym = access(sym, pos, site, names.init, true, argtypes, typeargtypes);
 1386  
         }
 1387  83
         return sym;
 1388  
     }
 1389  
 
 1390  
     /** Resolve constructor.
 1391  
      *  @param pos       The position to use for error reporting.
 1392  
      *  @param env       The environment current at the constructor invocation.
 1393  
      *  @param site      The type of class for which a constructor is searched.
 1394  
      *  @param argtypes  The types of the constructor invocation's value
 1395  
      *                   arguments.
 1396  
      *  @param typeargtypes  The types of the constructor invocation's type
 1397  
      *                   arguments.
 1398  
      *  @param allowBoxing Allow boxing and varargs conversions.
 1399  
      *  @param useVarargs Box trailing arguments into an array for varargs.
 1400  
      */
 1401  
     public // Javafx change
 1402  
     Symbol resolveConstructor(DiagnosticPosition pos, JavafxEnv<JavafxAttrContext> env,
 1403  
                               Type site, List<Type> argtypes,
 1404  
                               List<Type> typeargtypes,
 1405  
                               boolean allowBoxing,
 1406  
                               boolean useVarargs) {
 1407  110
         Symbol sym = findMethod(env, site,
 1408  
                                 names.init, argtypes,
 1409  
                                 typeargtypes, allowBoxing,
 1410  
                                 useVarargs, false);
 1411  110
         if ((sym.flags() & DEPRECATED) != 0 &&
 1412  
             (env.info.scope.owner.flags() & DEPRECATED) == 0 &&
 1413  
             env.info.scope.owner.outermostClass() != sym.outermostClass())
 1414  0
             chk.warnDeprecated(pos, sym);
 1415  110
         return sym;
 1416  
     }
 1417  
 
 1418  
     /** Resolve a constructor, throw a fatal error if not found.
 1419  
      *  @param pos       The position to use for error reporting.
 1420  
      *  @param env       The environment current at the method invocation.
 1421  
      *  @param site      The type to be constructed.
 1422  
      *  @param argtypes  The types of the invocation's value arguments.
 1423  
      *  @param typeargtypes  The types of the invocation's type arguments.
 1424  
      */
 1425  
     public MethodSymbol resolveInternalConstructor(DiagnosticPosition pos, JavafxEnv<JavafxAttrContext> env,
 1426  
                                         Type site,
 1427  
                                         List<Type> argtypes,
 1428  
                                         List<Type> typeargtypes) {
 1429  0
         Symbol sym = resolveConstructor(
 1430  
             pos, env, site, argtypes, typeargtypes);
 1431  0
         if (sym.kind == MTH) return (MethodSymbol)sym;
 1432  0
         else throw new FatalError(
 1433  
                  JCDiagnostic.fragment(MsgSym.MESSAGE_FATAL_ERR_CANNOT_LOCATE_CTOR, site));
 1434  
     }
 1435  
 
 1436  
     /** Resolve operator.
 1437  
      *  @param pos       The position to use for error reporting.
 1438  
      *  @param optag     The tag of the operation tree.
 1439  
      *  @param env       The environment current at the operation.
 1440  
      *  @param argtypes  The types of the operands.
 1441  
      */
 1442  
     Symbol resolveOperator(DiagnosticPosition pos, int optag,
 1443  
                            JavafxEnv<JavafxAttrContext> env, List<Type> argtypes) {
 1444  1563
         Name name = treeinfo.operatorName(optag);
 1445  1563
         Symbol sym = findMethod(env, syms.predefClass.type, name, argtypes,
 1446  
                                 null, false, false, true);
 1447  1563
         if (boxingEnabled && sym.kind >= WRONG_MTHS)
 1448  5
             sym = findMethod(env, syms.predefClass.type, name, argtypes,
 1449  
                              null, true, false, true);
 1450  1563
         return access(sym, pos, env.enclClass.sym.type, name,
 1451  
                       false, argtypes, null);
 1452  
     }
 1453  
 
 1454  
     /** Resolve operator.
 1455  
      *  @param pos       The position to use for error reporting.
 1456  
      *  @param optag     The tag of the operation tree.
 1457  
      *  @param env       The environment current at the operation.
 1458  
      *  @param arg       The type of the operand.
 1459  
      */
 1460  
     Symbol resolveUnaryOperator(DiagnosticPosition pos, int optag, JavafxEnv<JavafxAttrContext> env, Type arg) {
 1461  
         // check for Duration unary minus
 1462  432
         if (types.isSameType(arg, ((JavafxSymtab)syms).javafx_DurationType)) {
 1463  0
             Symbol res = null;
 1464  0
             switch (optag) {
 1465  
             case JCTree.NEG:
 1466  0
                 res = resolveMethod(pos,  env,
 1467  
                                     names.fromString("negate"),
 1468  
                                     arg, List.<Type>nil());
 1469  
                 break;
 1470  
             }
 1471  0
             if (res != null && res.kind == MTH) {
 1472  0
                 return res;
 1473  
             }
 1474  
         }
 1475  432
         return resolveOperator(pos, optag, env, List.of(arg));
 1476  
     }
 1477  
 
 1478  
     /** Resolve binary operator.
 1479  
      *  @param pos       The position to use for error reporting.
 1480  
      *  @param optag     The tag of the operation tree.
 1481  
      *  @param env       The environment current at the operation.
 1482  
      *  @param left      The types of the left operand.
 1483  
      *  @param right     The types of the right operand.
 1484  
      */
 1485  
     public // Javafx change
 1486  
     Symbol resolveBinaryOperator(DiagnosticPosition pos,
 1487  
                                  int optag,
 1488  
                                  JavafxEnv<JavafxAttrContext> env,
 1489  
                                  Type left,
 1490  
                                  Type right) {
 1491  
         // Duration operator overloading
 1492  1138
         if (types.isSameType(left, ((JavafxSymtab)syms).javafx_DurationType) ||
 1493  
             types.isSameType(right, ((JavafxSymtab)syms).javafx_DurationType)) {
 1494  7
             Type dur = left;
 1495  7
             Symbol res = null;
 1496  7
             switch (optag) {
 1497  
             case JCTree.PLUS:
 1498  4
                 res = resolveMethod(pos,  env,
 1499  
                                      names.fromString("add"),
 1500  
                                      dur, List.of(right));
 1501  4
                 break;
 1502  
             case JCTree.MINUS:
 1503  1
                 res =  resolveMethod(pos,  env,
 1504  
                                      names.fromString("sub"),
 1505  
                                      dur, List.of(right));
 1506  1
                 break;
 1507  
             case JCTree.MUL:
 1508  1
                 if (!types.isSameType(left, ((JavafxSymtab)syms).javafx_DurationType)) {
 1509  0
                     right = left;
 1510  0
                     dur = right;
 1511  
                 }
 1512  1
                 res =  resolveMethod(pos,  env,
 1513  
                                      names.fromString("mul"),
 1514  
                                      dur,
 1515  
                                      List.of(right));
 1516  1
                 break;
 1517  
             case JCTree.DIV:
 1518  1
                 res =  resolveMethod(pos,  env,
 1519  
                                      names.fromString("div"),
 1520  
                                      dur, List.of(right));
 1521  1
                 break;
 1522  
 
 1523  
             //fix me...inline or move to static helper?
 1524  
             case JCTree.LT:
 1525  0
                 res =  resolveMethod(pos,  env,
 1526  
                                      names.fromString("lt"),
 1527  
                                      dur, List.of(right));
 1528  0
                 break;
 1529  
             case JCTree.LE:
 1530  0
                 res =  resolveMethod(pos,  env,
 1531  
                                      names.fromString("le"),
 1532  
                                      dur, List.of(right));
 1533  0
                 break;
 1534  
             case JCTree.GT:
 1535  0
                 res =  resolveMethod(pos,  env,
 1536  
                                      names.fromString("gt"),
 1537  
                                      dur, List.of(right));
 1538  0
                 break;
 1539  
             case JCTree.GE:
 1540  0
                 res =  resolveMethod(pos,  env,
 1541  
                                      names.fromString("ge"),
 1542  
                                      dur, List.of(right));
 1543  
                 break;
 1544  
             }
 1545  7
             if (res != null && res.kind == MTH) {
 1546  7
                 return res;
 1547  
             } // else fall through
 1548  
         }
 1549  1131
         return resolveOperator(pos, optag, env, List.of(left, right));
 1550  
     }
 1551  
 
 1552  
     Symbol resolveMethod(DiagnosticPosition pos,
 1553  
                          JavafxEnv<JavafxAttrContext> env, 
 1554  
                          Name name,
 1555  
                          Type type,
 1556  
                          List<Type> argtypes) {
 1557  7
         Symbol sym = findMethod(env, type, name, argtypes,
 1558  
                                 null, true, false, false);
 1559  7
         if (sym.kind == MTH) { // skip access if method wasn't found
 1560  7
             return access(sym, pos, env.enclClass.sym.type, name,
 1561  
                           false, argtypes, null);
 1562  
         }
 1563  0
         return sym;
 1564  
     }
 1565  
 
 1566  
     /**
 1567  
      * Resolve `c.name' where name == this or name == super.
 1568  
      * @param pos           The position to use for error reporting.
 1569  
      * @param env           The environment current at the expression.
 1570  
      * @param c             The qualifier.
 1571  
      * @param name          The identifier's name.
 1572  
      */
 1573  
     public // Javafx change
 1574  
     Symbol resolveSelf(DiagnosticPosition pos,
 1575  
                        JavafxEnv<JavafxAttrContext> env,
 1576  
                        TypeSymbol c,
 1577  
                        Name name) {
 1578  0
         JavafxEnv<JavafxAttrContext> env1 = env;
 1579  0
         boolean staticOnly = false;
 1580  0
         while (env1.outer != null) {
 1581  0
             if (isStatic(env1)) staticOnly = true;
 1582  0
             if (env1.enclClass.sym == c) {
 1583  0
                 Symbol sym = env1.info.scope.lookup(name).sym;
 1584  0
                 if (sym != null) {
 1585  0
                     if (staticOnly) sym = new StaticError(sym);
 1586  0
                     return access(sym, pos, env.enclClass.sym.type,
 1587  
                                   name, true);
 1588  
                 }
 1589  
             }
 1590  0
             if ((env1.enclClass.sym.flags() & STATIC) != 0) staticOnly = true;
 1591  0
             env1 = env1.outer;
 1592  
         }
 1593  0
         log.error(pos, MsgSym.MESSAGE_NOT_ENCL_CLASS, c);
 1594  0
         return syms.errSymbol;
 1595  
     }
 1596  
 
 1597  
     /**
 1598  
      * Resolve `c.this' for an enclosing class c that contains the
 1599  
      * named member.
 1600  
      * @param pos           The position to use for error reporting.
 1601  
      * @param env           The environment current at the expression.
 1602  
      * @param member        The member that must be contained in the result.
 1603  
      */
 1604  
     Symbol resolveSelfContaining(DiagnosticPosition pos,
 1605  
                                  JavafxEnv<JavafxAttrContext> env,
 1606  
                                  Symbol member) {
 1607  0
         Name name = names._this;
 1608  0
         JavafxEnv<JavafxAttrContext> env1 = env;
 1609  0
         boolean staticOnly = false;
 1610  0
         while (env1.outer != null) {
 1611  0
             if (isStatic(env1)) staticOnly = true;
 1612  0
             if (env1.enclClass.sym.isSubClass(member.owner, types) &&
 1613  
                 isAccessible(env, env1.enclClass.sym.type, member)) {
 1614  0
                 Symbol sym = env1.info.scope.lookup(name).sym;
 1615  0
                 if (sym != null) {
 1616  0
                     if (staticOnly) sym = new StaticError(sym);
 1617  0
                     return access(sym, pos, env.enclClass.sym.type,
 1618  
                                   name, true);
 1619  
                 }
 1620  
             }
 1621  0
             if ((env1.enclClass.sym.flags() & STATIC) != 0)
 1622  0
                 staticOnly = true;
 1623  0
             env1 = env1.outer;
 1624  
         }
 1625  0
         log.error(pos, MsgSym.MESSAGE_ENCL_CLASS_REQUIRED, member);
 1626  0
         return syms.errSymbol;
 1627  
     }
 1628  
 
 1629  
     /**
 1630  
      * Resolve an appropriate implicit this instance for t's container.
 1631  
      * JLS2 8.8.5.1 and 15.9.2
 1632  
      */
 1633  
     public // Javafx change
 1634  
     Type resolveImplicitThis(DiagnosticPosition pos, JavafxEnv<JavafxAttrContext> env, Type t) {
 1635  0
         Type thisType = (((t.tsym.owner.kind & (MTH|VAR)) != 0)
 1636  
                          ? resolveSelf(pos, env, t.getEnclosingType().tsym, names._this)
 1637  
                          : resolveSelfContaining(pos, env, t.tsym)).type;
 1638  0
         if (env.info.isSelfCall && thisType.tsym == env.enclClass.sym)
 1639  0
             log.error(pos, MsgSym.MESSAGE_CANNOT_REF_BEFORE_CTOR_CALLED, "this");
 1640  0
         return thisType;
 1641  
     }
 1642  
 
 1643  
 /* ***************************************************************************
 1644  
  *  Methods related to kinds
 1645  
  ****************************************************************************/
 1646  
 
 1647  
     /** A localized string describing a given kind.
 1648  
      */
 1649  
     public // Javafx change
 1650  
     static JCDiagnostic kindName(int kind) {
 1651  0
         switch (kind) {
 1652  0
         case PCK: return JCDiagnostic.fragment(MsgSym.KINDNAME_PACKAGE);
 1653  0
         case TYP: return JCDiagnostic.fragment(MsgSym.KINDNAME_CLASS);
 1654  0
         case VAR: return JCDiagnostic.fragment(MsgSym.KINDNAME_VARIABLE);
 1655  0
         case VAL: return JCDiagnostic.fragment(MsgSym.KINDNAME_VALUE);
 1656  0
         case MTH: return JCDiagnostic.fragment(MsgSym.KINDNAME_METHOD);
 1657  0
         default : return JCDiagnostic.fragment(MsgSym.KINDNAME,
 1658  
                                                Integer.toString(kind)); //debug
 1659  
         }
 1660  
     }
 1661  
 
 1662  
     static JCDiagnostic kindName(Symbol sym) {
 1663  1
         switch (sym.getKind()) {
 1664  
         case PACKAGE:
 1665  0
             return JCDiagnostic.fragment(MsgSym.KINDNAME_PACKAGE);
 1666  
 
 1667  
         case ENUM:
 1668  
         case ANNOTATION_TYPE:
 1669  
         case INTERFACE:
 1670  
         case CLASS:
 1671  0
             return JCDiagnostic.fragment(MsgSym.KINDNAME_CLASS);
 1672  
 
 1673  
         case TYPE_PARAMETER:
 1674  0
             return JCDiagnostic.fragment(MsgSym.KINDNAME_TYPE_VARIABLE);
 1675  
 
 1676  
         case ENUM_CONSTANT:
 1677  
         case FIELD:
 1678  
         case PARAMETER:
 1679  
         case LOCAL_VARIABLE:
 1680  
         case EXCEPTION_PARAMETER:
 1681  0
             return JCDiagnostic.fragment(MsgSym.KINDNAME_VARIABLE);
 1682  
 
 1683  
         case METHOD:
 1684  
         case CONSTRUCTOR:
 1685  
         case STATIC_INIT:
 1686  
         case INSTANCE_INIT:
 1687  3
             return JCDiagnostic.fragment(MsgSym.KINDNAME_METHOD);
 1688  
 
 1689  
         default:
 1690  0
             if (sym.kind == VAL)
 1691  
                 // I don't think this can happen but it can't harm
 1692  
                 // playing it safe --ahe
 1693  0
                 return JCDiagnostic.fragment(MsgSym.KINDNAME_VALUE);
 1694  
             else
 1695  0
                 return JCDiagnostic.fragment(MsgSym.KINDNAME, sym.getKind()); // debug
 1696  
         }
 1697  
     }
 1698  
 
 1699  
     /** A localized string describing a given set of kinds.
 1700  
      */
 1701  
     public // Javafx change
 1702  
     static JCDiagnostic kindNames(int kind) {
 1703  0
         StringBuffer key = new StringBuffer();
 1704  0
         key.append(MsgSym.KINDNAME);
 1705  0
         if ((kind & VAL) != 0)
 1706  0
             key.append(((kind & VAL) == VAR) ? MsgSym.KINDNAME_KEY_VARIABLE : MsgSym.KINDNAME_KEY_VALUE);
 1707  0
         if ((kind & MTH) != 0) key.append(MsgSym.KINDNAME_KEY_METHOD);
 1708  0
         if ((kind & TYP) != 0) key.append(MsgSym.KINDNAME_KEY_CLASS);
 1709  0
         if ((kind & PCK) != 0) key.append(MsgSym.KINDNAME_KEY_PACKAGE);
 1710  0
         return JCDiagnostic.fragment(key.toString(), kind);
 1711  
     }
 1712  
 
 1713  
     /** A localized string describing the kind -- either class or interface --
 1714  
      *  of a given type.
 1715  
      */
 1716  
     static JCDiagnostic typeKindName(Type t) {
 1717  12
         if (t.tag == TYPEVAR ||
 1718  
             t.tag == CLASS && (t.tsym.flags() & COMPOUND) != 0)
 1719  0
             return JCDiagnostic.fragment(MsgSym.KINDNAME_TYPE_VARIABLE_BOUND);
 1720  12
         else if (t.tag == PACKAGE)
 1721  0
             return JCDiagnostic.fragment(MsgSym.KINDNAME_PACKAGE);
 1722  12
         else if ((t.tsym.flags_field & ANNOTATION) != 0)
 1723  0
             return JCDiagnostic.fragment(MsgSym.KINDNAME_ANNOTATION);
 1724  12
         else if ((t.tsym.flags_field & INTERFACE) != 0)
 1725  0
             return JCDiagnostic.fragment(MsgSym.KINDNAME_INTERFACE);
 1726  
         else
 1727  12
             return JCDiagnostic.fragment(MsgSym.KINDNAME_CLASS);
 1728  
     }
 1729  
 
 1730  
     /** A localized string describing the kind of a missing symbol, given an
 1731  
      *  error kind.
 1732  
      */
 1733  
     static JCDiagnostic absentKindName(int kind) {
 1734  22
         switch (kind) {
 1735  
         case ABSENT_VAR:
 1736  12
             return JCDiagnostic.fragment(MsgSym.KINDNAME_VARIABLE);
 1737  
         case WRONG_MTHS: case WRONG_MTH: case ABSENT_MTH:
 1738  6
             return JCDiagnostic.fragment(MsgSym.KINDNAME_METHOD);
 1739  
         case ABSENT_TYP:
 1740  4
             return JCDiagnostic.fragment(MsgSym.KINDNAME_CLASS);
 1741  
         default:
 1742  0
             return JCDiagnostic.fragment(MsgSym.KINDNAME, kind);
 1743  
         }
 1744  
     }
 1745  
 
 1746  
 /* ***************************************************************************
 1747  
  *  ResolveError classes, indicating error situations when accessing symbols
 1748  
  ****************************************************************************/
 1749  
 
 1750  
     public void logAccessError(JavafxEnv<JavafxAttrContext> env, JCTree tree, Type type) {
 1751  0
         AccessError error = new AccessError(env, type.getEnclosingType(), type.tsym);
 1752  0
         error.report(log, tree.pos(), type.getEnclosingType(), null, null, null);
 1753  0
     }
 1754  
 
 1755  
     /** Root class for resolve errors.
 1756  
      *  Instances of this class indicate "Symbol not found".
 1757  
      *  Instances of subclass indicate other errors.
 1758  
      */
 1759  
     private class ResolveError extends Symbol {
 1760  
 
 1761  2057
         ResolveError(int kind, Symbol sym, String debugName) {
 1762  2057
             super(kind, 0, null, null, null);
 1763  2057
             this.debugName = debugName;
 1764  2057
             this.sym = sym;
 1765  2057
         }
 1766  
 
 1767  
         /** The name of the kind of error, for debugging only.
 1768  
          */
 1769  
         final String debugName;
 1770  
 
 1771  
         /** The symbol that was determined by resolution, or errSymbol if none
 1772  
          *  was found.
 1773  
          */
 1774  
         final Symbol sym;
 1775  
 
 1776  
         /** The symbol that was a close mismatch, or null if none was found.
 1777  
          *  wrongSym is currently set if a simgle method with the correct name, but
 1778  
          *  the wrong parameters was found.
 1779  
          */
 1780  
         Symbol wrongSym;
 1781  
 
 1782  
         /** An auxiliary explanation set in case of instantiation errors.
 1783  
          */
 1784  
         JCDiagnostic explanation;
 1785  
 
 1786  
 
 1787  
         public <R, P> R accept(ElementVisitor<R, P> v, P p) {
 1788  0
             throw new AssertionError();
 1789  
         }
 1790  
 
 1791  
         /** Print the (debug only) name of the kind of error.
 1792  
          */
 1793  
         @Override
 1794  
         public String toString() {
 1795  0
             return debugName + " wrongSym=" + wrongSym + " explanation=" + explanation;
 1796  
         }
 1797  
 
 1798  
         /** Update wrongSym and explanation and return this.
 1799  
          */
 1800  
         ResolveError setWrongSym(Symbol sym, JCDiagnostic explanation) {
 1801  13
             this.wrongSym = sym;
 1802  13
             this.explanation = explanation;
 1803  13
             return this;
 1804  
         }
 1805  
 
 1806  
         /** Update wrongSym and return this.
 1807  
          */
 1808  
         ResolveError setWrongSym(Symbol sym) {
 1809  1480
             this.wrongSym = sym;
 1810  1480
             this.explanation = null;
 1811  1480
             return this;
 1812  
         }
 1813  
 
 1814  
         @Override
 1815  
         public boolean exists() {
 1816  17760
             switch (kind) {
 1817  
             case HIDDEN:
 1818  
             case ABSENT_VAR:
 1819  
             case ABSENT_MTH:
 1820  
             case ABSENT_TYP:
 1821  17754
                 return false;
 1822  
             default:
 1823  6
                 return true;
 1824  
             }
 1825  
         }
 1826  
 
 1827  
         /** Report error.
 1828  
          *  @param log       The error log to be used for error reporting.
 1829  
          *  @param pos       The position to be used for error reporting.
 1830  
          *  @param site      The original type from where the selection took place.
 1831  
          *  @param name      The name of the symbol to be resolved.
 1832  
          *  @param argtypes  The invocation's value arguments,
 1833  
          *                   if we looked for a method.
 1834  
          *  @param typeargtypes  The invocation's type arguments,
 1835  
          *                   if we looked for a method.
 1836  
          */
 1837  
         void report(Log log, DiagnosticPosition pos, Type site, Name name,
 1838  
                     List<Type> argtypes, List<Type> typeargtypes) {
 1839  22
             if (name != name.table.error) {
 1840  22
                 JCDiagnostic kindname = absentKindName(kind);
 1841  22
                 String idname = name.toString();
 1842  22
                 String args = "";
 1843  22
                 String typeargs = "";
 1844  22
                 if (kind >= WRONG_MTHS && kind <= ABSENT_MTH) {
 1845  6
                     if (isOperator(name)) {
 1846  0
                         log.error(pos, MsgSym.MESSAGE_OPERATOR_CANNOT_BE_APPLIED,
 1847  
                                   name, Type.toString(argtypes));
 1848  0
                         return;
 1849  
                     }
 1850  6
                     if (name == name.table.init) {
 1851  0
                         kindname = JCDiagnostic.fragment(MsgSym.KINDNAME_CONSTRUCTOR);
 1852  0
                         idname = site.tsym.name.toString();
 1853  
                     }
 1854  6
                     args = "(" + Type.toString(argtypes) + ")";
 1855  6
                     if (typeargtypes != null && typeargtypes.nonEmpty())
 1856  0
                         typeargs = "<" + Type.toString(typeargtypes) + ">";
 1857  
                 }
 1858  22
                 if (kind == WRONG_MTH) {
 1859  6
                     Symbol wrongSymMem = wrongSym.asMemberOf(site, types);
 1860  
                     String wrongSymStr;
 1861  6
                     if (wrongSymMem instanceof MethodSymbol)
 1862  5
                         wrongSymStr =
 1863  
                                 types.toJavaFXString((MethodSymbol) wrongSymMem,
 1864  
                                     ((MethodSymbol) wrongSym).params);
 1865  
                     else
 1866  1
                         wrongSymStr = wrongSymMem.toString();
 1867  6
                     log.error(pos,
 1868  
                               MsgSym.MESSAGE_CANNOT_APPLY_SYMBOL + (explanation != null ? ".1" : ""),
 1869  
                               wrongSymStr,
 1870  
                               types.location(wrongSym, site),
 1871  
                               typeargs,
 1872  
                               types.toJavaFXString(argtypes),
 1873  
                               explanation);
 1874  6
                 } else if (site.tsym.name.len != 0) {
 1875  14
                     if (site.tsym.kind == PCK && !site.tsym.exists())
 1876  2
                         log.error(pos, MsgSym.MESSAGE_DOES_NOT_EXIST, site.tsym);
 1877  
                     else
 1878  12
                         log.error(pos, MsgSym.MESSAGE_CANNOT_RESOLVE_LOCATION,
 1879  
                                   kindname, idname, args, typeargs,
 1880  
                                   typeKindName(site), site);
 1881  
                 } else {
 1882  2
                     log.error(pos, MsgSym.MESSAGE_CANNOT_RESOLVE, kindname, idname, args, typeargs);
 1883  
                 }
 1884  
             }
 1885  22
         }
 1886  
 //where
 1887  
             /** A name designates an operator if it consists
 1888  
              *  of a non-empty sequence of operator symbols +-~!/*%&|^<>=
 1889  
              */
 1890  
             boolean isOperator(Name name) {
 1891  6
                 int i = 0;
 1892  
                 while (i < name.len &&
 1893  6
                        "+-~!*/%&|^<>=".indexOf(name.byteAt(i)) >= 0) i++;
 1894  6
                 return i > 0 && i == name.len;
 1895  
             }
 1896  
     }
 1897  
 
 1898  
     /** Resolve error class indicating that a symbol is not accessible.
 1899  
      */
 1900  
     class AccessError extends ResolveError {
 1901  
 
 1902  
         AccessError(Symbol sym) {
 1903  0
             this(null, null, sym);
 1904  0
         }
 1905  
 
 1906  21
         AccessError(JavafxEnv<JavafxAttrContext> env, Type site, Symbol sym) {
 1907  21
             super(HIDDEN, sym, "access error");
 1908  21
             this.env = env;
 1909  21
             this.site = site;
 1910  21
             if (debugResolve)
 1911  0
                 log.error(MsgSym.MESSAGE_PROC_MESSAGER, sym + " @ " + site + " is inaccessible.");
 1912  21
         }
 1913  
 
 1914  
         private JavafxEnv<JavafxAttrContext> env;
 1915  
         private Type site;
 1916  
 
 1917  
         /** Report error.
 1918  
          *  @param log       The error log to be used for error reporting.
 1919  
          *  @param pos       The position to be used for error reporting.
 1920  
          *  @param site      The original type from where the selection took place.
 1921  
          *  @param name      The name of the symbol to be resolved.
 1922  
          *  @param argtypes  The invocation's value arguments,
 1923  
          *                   if we looked for a method.
 1924  
          *  @param typeargtypes  The invocation's type arguments,
 1925  
          *                   if we looked for a method.
 1926  
          */
 1927  
         @Override
 1928  
         void report(Log log, DiagnosticPosition pos, Type site, Name name,
 1929  
                     List<Type> argtypes, List<Type> typeargtypes) {
 1930  0
             if (sym.owner.type.tag != ERROR) {
 1931  0
                 if (sym.name == sym.name.table.init && sym.owner != site.tsym)
 1932  0
                     new ResolveError(ABSENT_MTH, sym.owner, "absent method " + sym).report(
 1933  
                         log, pos, site, name, argtypes, typeargtypes);
 1934  0
                 if ((sym.flags() & PUBLIC) != 0
 1935  
                     || (env != null && this.site != null
 1936  
                         && !isAccessible(env, this.site)))
 1937  0
                     log.error(pos, MsgSym.MESSAGE_NOT_DEF_ACCESS_CLASS_INTF_CANNOT_ACCESS,
 1938  
                         sym, sym.location());
 1939  0
                 else if ((sym.flags() & (PRIVATE | PROTECTED)) != 0)
 1940  0
                     log.error(pos, MsgSym.MESSAGE_REPORT_ACCESS, sym,
 1941  
                               TreeInfo.flagNames(sym.flags() & (PRIVATE | PROTECTED)),
 1942  
                               sym.location());
 1943  
                 else
 1944  0
                     log.error(pos, MsgSym.MESSAGE_NOT_DEF_PUBLIC_CANNOT_ACCESS,
 1945  
                               sym, sym.location());
 1946  
             }
 1947  0
         }
 1948  
     }
 1949  
 
 1950  
     /** Resolve error class indicating that an instance member was accessed
 1951  
      *  from a static context.
 1952  
      */
 1953  
     class StaticError extends ResolveError {
 1954  1
         StaticError(Symbol sym) {
 1955  1
             super(STATICERR, sym, "static error");
 1956  1
         }
 1957  
 
 1958  
         /** Report error.
 1959  
          *  @param log       The error log to be used for error reporting.
 1960  
          *  @param pos       The position to be used for error reporting.
 1961  
          *  @param site      The original type from where the selection took place.
 1962  
          *  @param name      The name of the symbol to be resolved.
 1963  
          *  @param argtypes  The invocation's value arguments,
 1964  
          *                   if we looked for a method.
 1965  
          *  @param typeargtypes  The invocation's type arguments,
 1966  
          *                   if we looked for a method.
 1967  
          */
 1968  
         @Override
 1969  
         void report(Log log,
 1970  
                     DiagnosticPosition pos,
 1971  
                     Type site,
 1972  
                     Name name,
 1973  
                     List<Type> argtypes,
 1974  
                     List<Type> typeargtypes) {
 1975  1
             String symstr = ((sym.kind == TYP && sym.type.tag == CLASS)
 1976  
                 ? types.erasure(sym.type)
 1977  
                 : sym).toString();
 1978  1
             log.error(pos, MsgSym.MESSAGE_NON_STATIC_CANNOT_BE_REF,
 1979  
                       kindName(sym), symstr);
 1980  1
         }
 1981  
     }
 1982  
 
 1983  
     /** Resolve error class indicating an ambiguous reference.
 1984  
      */
 1985  
     class AmbiguityError extends ResolveError {
 1986  
         Symbol sym1;
 1987  
         Symbol sym2;
 1988  
 
 1989  40
         AmbiguityError(Symbol sym1, Symbol sym2) {
 1990  40
             super(AMBIGUOUS, sym1, "ambiguity error");
 1991  40
             this.sym1 = sym1;
 1992  40
             this.sym2 = sym2;
 1993  40
         }
 1994  
 
 1995  
         /** Report error.
 1996  
          *  @param log       The error log to be used for error reporting.
 1997  
          *  @param pos       The position to be used for error reporting.
 1998  
          *  @param site      The original type from where the selection took place.
 1999  
          *  @param name      The name of the symbol to be resolved.
 2000  
          *  @param argtypes  The invocation's value arguments,
 2001  
          *                   if we looked for a method.
 2002  
          *  @param typeargtypes  The invocation's type arguments,
 2003  
          *                   if we looked for a method.
 2004  
          */
 2005  
         @Override
 2006  
         void report(Log log, DiagnosticPosition pos, Type site, Name name,
 2007  
                     List<Type> argtypes, List<Type> typeargtypes) {
 2008  1
             AmbiguityError pair = this;
 2009  
             while (true) {
 2010  1
                 if (pair.sym1.kind == AMBIGUOUS)
 2011  0
                     pair = (AmbiguityError)pair.sym1;
 2012  1
                 else if (pair.sym2.kind == AMBIGUOUS)
 2013  0
                     pair = (AmbiguityError)pair.sym2;
 2014  
                 else break;
 2015  
             }
 2016  1
             Name sname = pair.sym1.name;
 2017  1
             if (sname == sname.table.init) sname = pair.sym1.owner.name;
 2018  1
             log.error(pos, MsgSym.MESSAGE_REF_AMBIGUOUS, sname,
 2019  
                       kindName(pair.sym1),
 2020  
                       pair.sym1,
 2021  
                       types.location(pair.sym1, site),
 2022  
                       kindName(pair.sym2),
 2023  
                       pair.sym2,
 2024  
                       types.location(pair.sym2, site));
 2025  1
         }
 2026  
     }
 2027  
 
 2028  
     public boolean isInheritedIn(Symbol sym, Symbol clazz, JavafxTypes types) {
 2029  50029
         switch ((int)(sym.flags_field & Flags.AccessFlags)) {
 2030  
         default: // error recovery
 2031  
         case PUBLIC:
 2032  25216
             return true;
 2033  
         case PRIVATE:
 2034  49
             return sym.owner == clazz;
 2035  
         case PROTECTED:
 2036  
             // we model interfaces as extending Object
 2037  13
             return (clazz.flags() & INTERFACE) == 0;
 2038  
         case 0:
 2039  24751
             ListBuffer<Type> supertypes = ListBuffer.<Type>lb();
 2040  24751
             Set superSet = new HashSet<Type>();
 2041  24751
             if (clazz.type != null) {
 2042  24751
                 supertypes.append(clazz.type);
 2043  24751
                 superSet.add(clazz.type);
 2044  
             }
 2045  24751
             types.getSupertypes(clazz, supertypes, superSet);
 2046  
 
 2047  24751
             boolean foundInherited = false;
 2048  24751
             for (Type supType : supertypes.toList()) {
 2049  50185
                 if (supType.tsym == sym.owner) {
 2050  3061
                     foundInherited = true;
 2051  3061
                     break;
 2052  
                 }
 2053  47124
                 else if (supType.isErroneous()) {
 2054  0
                     return true; // Error recovery
 2055  
                 }
 2056  47124
                 else if (supType.tsym != null && (supType.tsym.flags() & COMPOUND) != 0) {
 2057  0
                     continue;
 2058  
                 }
 2059  
             }
 2060  24751
             return foundInherited && (clazz.flags() & INTERFACE) == 0;
 2061  
         }
 2062  
     }
 2063  
 }