langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java
changeset 14359 d4099818ab70
parent 14258 8d2148961366
child 14443 91c05eb19277
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java	Tue Oct 23 13:58:56 2012 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java	Thu Oct 25 11:09:36 2012 -0700
@@ -42,7 +42,9 @@
 import com.sun.tools.javac.util.Name;
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
+import static com.sun.tools.javac.code.TypeTag.FORALL;
+import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
 
 /** Root class for Java symbols. It contains subclasses
  *  for specific sorts of symbols, such as variables, methods and operators,
@@ -161,7 +163,7 @@
         if (owner.name == null || owner.name.isEmpty()) {
             return location();
         }
-        if (owner.type.tag == CLASS) {
+        if (owner.type.hasTag(CLASS)) {
             Type ownertype = types.asOuterSuper(site, owner);
             if (ownertype != null) return ownertype.tsym;
         }
@@ -256,7 +258,7 @@
     /** A class is an inner class if it it has an enclosing instance class.
      */
     public boolean isInner() {
-        return type.getEnclosingType().tag == CLASS;
+        return type.getEnclosingType().hasTag(CLASS);
     }
 
     /** An inner class has an outer instance if it is not an interface
@@ -269,7 +271,7 @@
      */
     public boolean hasOuterInstance() {
         return
-            type.getEnclosingType().tag == CLASS && (flags() & (INTERFACE | NOOUTERTHIS)) == 0;
+            type.getEnclosingType().hasTag(CLASS) && (flags() & (INTERFACE | NOOUTERTHIS)) == 0;
     }
 
     /** The closest enclosing class of this symbol's declaration.
@@ -277,7 +279,7 @@
     public ClassSymbol enclClass() {
         Symbol c = this;
         while (c != null &&
-               ((c.kind & TYP) == 0 || c.type.tag != CLASS)) {
+               ((c.kind & TYP) == 0 || !c.type.hasTag(CLASS))) {
             c = c.owner;
         }
         return (ClassSymbol)c;
@@ -346,7 +348,7 @@
                 e = e.next();
             }
             Type superType = types.supertype(clazz.type);
-            if (superType.tag != TypeTags.CLASS) return false;
+            if (!superType.hasTag(CLASS)) return false;
             clazz = (ClassSymbol)superType.tsym;
         }
     }
@@ -373,7 +375,7 @@
             for (Symbol sup = clazz;
                  sup != null && sup != this.owner;
                  sup = types.supertype(sup.type).tsym) {
-                while (sup.type.tag == TYPEVAR)
+                while (sup.type.hasTag(TYPEVAR))
                     sup = sup.type.getUpperBound().tsym;
                 if (sup.type.isErroneous())
                     return true; // error recovery
@@ -520,7 +522,7 @@
             if (owner == null) return name;
             if (((owner.kind != ERR)) &&
                 ((owner.kind & (VAR | MTH)) != 0
-                 || (owner.kind == TYP && owner.type.tag == TYPEVAR)
+                 || (owner.kind == TYP && owner.type.hasTag(TYPEVAR))
                  )) return name;
             Name prefix = owner.getQualifiedName();
             if (prefix == null || prefix == prefix.table.names.empty)
@@ -534,7 +536,7 @@
         static public Name formFlatName(Name name, Symbol owner) {
             if (owner == null ||
                 (owner.kind & (VAR | MTH)) != 0
-                || (owner.kind == TYP && owner.type.tag == TYPEVAR)
+                || (owner.kind == TYP && owner.type.hasTag(TYPEVAR))
                 ) return name;
             char sep = owner.kind == TYP ? '$' : '.';
             Name prefix = owner.flatName();
@@ -553,16 +555,16 @@
             if (this == that)
                 return false;
             if (this.type.tag == that.type.tag) {
-                if (this.type.tag == CLASS) {
+                if (this.type.hasTag(CLASS)) {
                     return
                         types.rank(that.type) < types.rank(this.type) ||
                         types.rank(that.type) == types.rank(this.type) &&
                         that.getQualifiedName().compareTo(this.getQualifiedName()) < 0;
-                } else if (this.type.tag == TYPEVAR) {
+                } else if (this.type.hasTag(TYPEVAR)) {
                     return types.isSubtype(this.type, that.type);
                 }
             }
-            return this.type.tag == TYPEVAR;
+            return this.type.hasTag(TYPEVAR);
         }
 
         // For type params; overridden in subclasses.
@@ -572,7 +574,7 @@
 
         public java.util.List<Symbol> getEnclosedElements() {
             List<Symbol> list = List.nil();
-            if (kind == TYP && type.tag == TYPEVAR) {
+            if (kind == TYP && type.hasTag(TYPEVAR)) {
                 return list;
             }
             for (Scope.Entry e = members().elems; e != null; e = e.sibling) {
@@ -591,7 +593,7 @@
         }
 
         public <R, P> R accept(ElementVisitor<R, P> v, P p) {
-            Assert.check(type.tag == TYPEVAR); // else override will be invoked
+            Assert.check(type.hasTag(TYPEVAR)); // else override will be invoked
             return v.visitTypeParameter(this, p);
         }
 
@@ -798,13 +800,13 @@
             if (this == base) {
                 return true;
             } else if ((base.flags() & INTERFACE) != 0) {
-                for (Type t = type; t.tag == CLASS; t = types.supertype(t))
+                for (Type t = type; t.hasTag(CLASS); t = types.supertype(t))
                     for (List<Type> is = types.interfaces(t);
                          is.nonEmpty();
                          is = is.tail)
                         if (is.head.tsym.isSubClass(base, types)) return true;
             } else {
-                for (Type t = type; t.tag == CLASS; t = types.supertype(t))
+                for (Type t = type; t.hasTag(CLASS); t = types.supertype(t))
                     if (t.tsym == base) return true;
             }
             return false;
@@ -1048,7 +1050,7 @@
          */
         public MethodSymbol(long flags, Name name, Type type, Symbol owner) {
             super(MTH, flags, name, type, owner);
-            if (owner.type.tag == TYPEVAR) Assert.error(owner + "." + name);
+            if (owner.type.hasTag(TYPEVAR)) Assert.error(owner + "." + name);
         }
 
         /** Clone this symbol with new owner.
@@ -1074,7 +1076,7 @@
                     ? owner.name.toString()
                     : name.toString();
                 if (type != null) {
-                    if (type.tag == FORALL)
+                    if (type.hasTag(FORALL))
                         s = "<" + ((ForAll)type).getTypeArguments() + ">" + s;
                     s += "(" + type.argtypes((flags() & VARARGS) != 0) + ")";
                 }