langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java
equal
deleted
inserted
replaced
47 import com.sun.tools.javac.tree.TreeInfo; |
47 import com.sun.tools.javac.tree.TreeInfo; |
48 import com.sun.tools.javac.tree.TreeScanner; |
48 import com.sun.tools.javac.tree.TreeScanner; |
49 import com.sun.tools.javac.util.*; |
49 import com.sun.tools.javac.util.*; |
50 import com.sun.tools.javac.util.DefinedBy.Api; |
50 import com.sun.tools.javac.util.DefinedBy.Api; |
51 import com.sun.tools.javac.util.Name; |
51 import com.sun.tools.javac.util.Name; |
|
52 import static com.sun.tools.javac.code.Kinds.Kind.*; |
52 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; |
53 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; |
53 import static com.sun.tools.javac.code.TypeTag.CLASS; |
54 import static com.sun.tools.javac.code.TypeTag.CLASS; |
54 import static com.sun.tools.javac.tree.JCTree.Tag.*; |
55 import static com.sun.tools.javac.tree.JCTree.Tag.*; |
55 |
56 |
56 /** |
57 /** |
118 if (sym == null) |
119 if (sym == null) |
119 sym = javaCompiler.resolveIdent(nameStr); |
120 sym = javaCompiler.resolveIdent(nameStr); |
120 |
121 |
121 sym.complete(); |
122 sym.complete(); |
122 |
123 |
123 return (sym.kind != Kinds.ERR && |
124 return (sym.kind != ERR && |
124 sym.exists() && |
125 sym.exists() && |
125 clazz.isInstance(sym) && |
126 clazz.isInstance(sym) && |
126 name.equals(sym.getQualifiedName())) |
127 name.equals(sym.getQualifiedName())) |
127 ? clazz.cast(sym) |
128 ? clazz.cast(sym) |
128 : null; |
129 : null; |
458 return false; |
459 return false; |
459 } |
460 } |
460 |
461 |
461 // Only static methods can hide other methods. |
462 // Only static methods can hide other methods. |
462 // Methods only hide methods with matching signatures. |
463 // Methods only hide methods with matching signatures. |
463 if (hider.kind == Kinds.MTH) { |
464 if (hider.kind == MTH) { |
464 if (!hider.isStatic() || |
465 if (!hider.isStatic() || |
465 !types.isSubSignature(hider.type, hidee.type)) { |
466 !types.isSubSignature(hider.type, hidee.type)) { |
466 return false; |
467 return false; |
467 } |
468 } |
468 } |
469 } |
590 * Returns a symbol's enter environment, or null if it has none. |
591 * Returns a symbol's enter environment, or null if it has none. |
591 */ |
592 */ |
592 private Env<AttrContext> getEnterEnv(Symbol sym) { |
593 private Env<AttrContext> getEnterEnv(Symbol sym) { |
593 // Get enclosing class of sym, or sym itself if it is a class |
594 // Get enclosing class of sym, or sym itself if it is a class |
594 // or package. |
595 // or package. |
595 TypeSymbol ts = (sym.kind != Kinds.PCK) |
596 TypeSymbol ts = (sym.kind != PCK) |
596 ? sym.enclClass() |
597 ? sym.enclClass() |
597 : (PackageSymbol) sym; |
598 : (PackageSymbol) sym; |
598 return (ts != null) |
599 return (ts != null) |
599 ? enter.getEnv(ts) |
600 ? enter.getEnv(ts) |
600 : null; |
601 : null; |