langtools/src/share/classes/com/sun/tools/javac/code/Types.java
changeset 18646 e628560a86d1
parent 18412 d0e713f5cabd
child 18662 1cac45e71eb9
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Jun 24 22:03:57 2013 -0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Tue Jun 25 16:12:53 2013 +0100
@@ -286,8 +286,9 @@
      * conversion to s?
      */
     public boolean isConvertible(Type t, Type s, Warner warn) {
-        if (t.tag == ERROR)
+        if (t.hasTag(ERROR)) {
             return true;
+        }
         boolean tPrimitive = t.isPrimitive();
         boolean sPrimitive = s.isPrimitive();
         if (tPrimitive == sPrimitive) {
@@ -396,7 +397,8 @@
         /**
          * Compute the function descriptor associated with a given functional interface
          */
-        public FunctionDescriptor findDescriptorInternal(TypeSymbol origin, CompoundScope membersCache) throws FunctionDescriptorLookupError {
+        public FunctionDescriptor findDescriptorInternal(TypeSymbol origin,
+                CompoundScope membersCache) throws FunctionDescriptorLookupError {
             if (!origin.isInterface() || (origin.flags() & ANNOTATION) != 0) {
                 //t must be an interface
                 throw failure("not.a.functional.intf", origin);
@@ -655,17 +657,16 @@
                 }
             } else if (isSubtype(t, s)) {
                 return true;
-            }
-            else if (t.tag == TYPEVAR) {
+            } else if (t.hasTag(TYPEVAR)) {
                 return isSubtypeUnchecked(t.getUpperBound(), s, warn);
-            }
-            else if (!s.isRaw()) {
+            } else if (!s.isRaw()) {
                 Type t2 = asSuper(t, s.tsym);
                 if (t2 != null && t2.isRaw()) {
-                    if (isReifiable(s))
+                    if (isReifiable(s)) {
                         warn.silentWarn(LintCategory.UNCHECKED);
-                    else
+                    } else {
                         warn.warn(LintCategory.UNCHECKED);
+                    }
                     return true;
                 }
             }
@@ -673,13 +674,14 @@
         }
 
         private void checkUnsafeVarargsConversion(Type t, Type s, Warner warn) {
-            if (t.tag != ARRAY || isReifiable(t))
+            if (!t.hasTag(ARRAY) || isReifiable(t)) {
                 return;
+            }
             t = t.unannotatedType();
             s = s.unannotatedType();
             ArrayType from = (ArrayType)t;
             boolean shouldWarn = false;
-            switch (s.tag) {
+            switch (s.getTag()) {
                 case ARRAY:
                     ArrayType to = (ArrayType)s;
                     shouldWarn = from.isVarargs() &&
@@ -735,8 +737,9 @@
     // where
         private TypeRelation isSubtype = new TypeRelation()
         {
+            @Override
             public Boolean visitType(Type t, Type s) {
-                switch (t.tag) {
+                switch (t.getTag()) {
                  case BYTE:
                      return (!s.hasTag(CHAR) && t.getTag().isSubRangeOf(s.getTag()));
                  case CHAR:
@@ -756,7 +759,7 @@
                  case NONE:
                      return false;
                  default:
-                     throw new AssertionError("isSubtype " + t.tag);
+                     throw new AssertionError("isSubtype " + t.getTag());
                  }
             }
 
@@ -826,14 +829,14 @@
 
             @Override
             public Boolean visitArrayType(ArrayType t, Type s) {
-                if (s.tag == ARRAY) {
+                if (s.hasTag(ARRAY)) {
                     if (t.elemtype.isPrimitive())
                         return isSameType(t.elemtype, elemtype(s));
                     else
                         return isSubtypeNoCapture(t.elemtype, elemtype(s));
                 }
 
-                if (s.tag == CLASS) {
+                if (s.hasTag(CLASS)) {
                     Name sname = s.tsym.getQualifiedName();
                     return sname == names.java_lang_Object
                         || sname == names.java_lang_Cloneable
@@ -846,9 +849,9 @@
             @Override
             public Boolean visitUndetVar(UndetVar t, Type s) {
                 //todo: test against origin needed? or replace with substitution?
-                if (t == s || t.qtype == s || s.tag == ERROR || s.tag == UNKNOWN) {
+                if (t == s || t.qtype == s || s.hasTag(ERROR) || s.hasTag(UNKNOWN)) {
                     return true;
-                } else if (s.tag == BOT) {
+                } else if (s.hasTag(BOT)) {
                     //if 's' is 'null' there's no instantiated type U for which
                     //U <: s (but 'null' itself, which is not a valid type)
                     return false;
@@ -913,15 +916,17 @@
      * Is t a supertype of s?
      */
     public boolean isSuperType(Type t, Type s) {
-        switch (t.tag) {
+        switch (t.getTag()) {
         case ERROR:
             return true;
         case UNDETVAR: {
             UndetVar undet = (UndetVar)t;
             if (t == s ||
                 undet.qtype == s ||
-                s.tag == ERROR ||
-                s.tag == BOT) return true;
+                s.hasTag(ERROR) ||
+                s.hasTag(BOT)) {
+                return true;
+            }
             undet.addBound(InferenceBound.LOWER, s, this);
             return true;
         }
@@ -990,12 +995,12 @@
                 if (s.isPartial())
                     return visit(s, t);
 
-                switch (t.tag) {
+                switch (t.getTag()) {
                 case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT:
                 case DOUBLE: case BOOLEAN: case VOID: case BOT: case NONE:
-                    return t.tag == s.tag;
+                    return t.hasTag(s.getTag());
                 case TYPEVAR: {
-                    if (s.tag == TYPEVAR) {
+                    if (s.hasTag(TYPEVAR)) {
                         //type-substitution does not preserve type-var types
                         //check that type var symbols and bounds are indeed the same
                         return sameTypeVars((TypeVar)t.unannotatedType(), (TypeVar)s.unannotatedType());
@@ -1009,7 +1014,7 @@
                     }
                 }
                 default:
-                    throw new AssertionError("isSameType " + t.tag);
+                    throw new AssertionError("isSameType " + t.getTag());
                 }
             }
 
@@ -1080,8 +1085,9 @@
 
             @Override
             public Boolean visitForAll(ForAll t, Type s) {
-                if (s.tag != FORALL)
+                if (!s.hasTag(FORALL)) {
                     return false;
+                }
 
                 ForAll forAll = (ForAll)s;
                 return hasSameBounds(t, forAll)
@@ -1090,12 +1096,14 @@
 
             @Override
             public Boolean visitUndetVar(UndetVar t, Type s) {
-                if (s.tag == WILDCARD)
+                if (s.hasTag(WILDCARD)) {
                     // FIXME, this might be leftovers from before capture conversion
                     return false;
-
-                if (t == s || t.qtype == s || s.tag == ERROR || s.tag == UNKNOWN)
+                }
+
+                if (t == s || t.qtype == s || s.hasTag(ERROR) || s.hasTag(UNKNOWN)) {
                     return true;
+                }
 
                 t.addBound(InferenceBound.EQ, s, Types.this);
 
@@ -1171,9 +1179,9 @@
 
     // <editor-fold defaultstate="collapsed" desc="Contains Type">
     public boolean containedBy(Type t, Type s) {
-        switch (t.tag) {
+        switch (t.getTag()) {
         case UNDETVAR:
-            if (s.tag == WILDCARD) {
+            if (s.hasTag(WILDCARD)) {
                 UndetVar undetvar = (UndetVar)t;
                 WildcardType wt = (WildcardType)s.unannotatedType();
                 switch(wt.kind) {
@@ -1241,7 +1249,7 @@
         private TypeRelation containsType = new TypeRelation() {
 
             private Type U(Type t) {
-                while (t.tag == WILDCARD) {
+                while (t.hasTag(WILDCARD)) {
                     WildcardType w = (WildcardType)t.unannotatedType();
                     if (w.isSuperBound())
                         return w.bound == null ? syms.objectType : w.bound.bound;
@@ -1252,7 +1260,7 @@
             }
 
             private Type L(Type t) {
-                while (t.tag == WILDCARD) {
+                while (t.hasTag(WILDCARD)) {
                     WildcardType w = (WildcardType)t.unannotatedType();
                     if (w.isExtendsBound())
                         return syms.botType;
@@ -1298,10 +1306,11 @@
 
             @Override
             public Boolean visitUndetVar(UndetVar t, Type s) {
-                if (s.tag != WILDCARD)
+                if (!s.hasTag(WILDCARD)) {
                     return isSameType(t, s);
-                else
+                } else {
                     return false;
+                }
             }
 
             @Override
@@ -1311,13 +1320,13 @@
         };
 
     public boolean isCaptureOf(Type s, WildcardType t) {
-        if (s.tag != TYPEVAR || !((TypeVar)s.unannotatedType()).isCaptured())
+        if (!s.hasTag(TYPEVAR) || !((TypeVar)s.unannotatedType()).isCaptured())
             return false;
         return isSameWildcard(t, ((CapturedType)s.unannotatedType()).wildcard);
     }
 
     public boolean isSameWildcard(WildcardType t, Type s) {
-        if (s.tag != WILDCARD)
+        if (!s.hasTag(WILDCARD))
             return false;
         WildcardType w = (WildcardType)s.unannotatedType();
         return w.kind == t.kind && w.type == t.type;
@@ -1369,15 +1378,15 @@
         private TypeRelation isCastable = new TypeRelation() {
 
             public Boolean visitType(Type t, Type s) {
-                if (s.tag == ERROR)
+                if (s.hasTag(ERROR))
                     return true;
 
-                switch (t.tag) {
+                switch (t.getTag()) {
                 case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT:
                 case DOUBLE:
                     return s.isNumeric();
                 case BOOLEAN:
-                    return s.tag == BOOLEAN;
+                    return s.hasTag(BOOLEAN);
                 case VOID:
                     return false;
                 case BOT:
@@ -1394,10 +1403,10 @@
 
             @Override
             public Boolean visitClassType(ClassType t, Type s) {
-                if (s.tag == ERROR || s.tag == BOT)
+                if (s.hasTag(ERROR) || s.hasTag(BOT))
                     return true;
 
-                if (s.tag == TYPEVAR) {
+                if (s.hasTag(TYPEVAR)) {
                     if (isCastable(t, s.getUpperBound(), noWarnings)) {
                         warnStack.head.warn(LintCategory.UNCHECKED);
                         return true;
@@ -1412,11 +1421,11 @@
                             visitIntersectionType((IntersectionClassType)t.unannotatedType(), s, false);
                 }
 
-                if (s.tag == CLASS || s.tag == ARRAY) {
+                if (s.hasTag(CLASS) || s.hasTag(ARRAY)) {
                     boolean upcast;
                     if ((upcast = isSubtype(erasure(t), erasure(s)))
                         || isSubtype(erasure(s), erasure(t))) {
-                        if (!upcast && s.tag == ARRAY) {
+                        if (!upcast && s.hasTag(ARRAY)) {
                             if (!isReifiable(s))
                                 warnStack.head.warn(LintCategory.UNCHECKED);
                             return true;
@@ -1469,7 +1478,7 @@
                     }
 
                     // Sidecast
-                    if (s.tag == CLASS) {
+                    if (s.hasTag(CLASS)) {
                         if ((s.tsym.flags() & INTERFACE) != 0) {
                             return ((t.tsym.flags() & FINAL) == 0)
                                 ? sideCast(t, s, warnStack.head)
@@ -1501,7 +1510,7 @@
 
             @Override
             public Boolean visitArrayType(ArrayType t, Type s) {
-                switch (s.tag) {
+                switch (s.getTag()) {
                 case ERROR:
                 case BOT:
                     return true;
@@ -1516,7 +1525,7 @@
                     return isSubtype(t, s);
                 case ARRAY:
                     if (elemtype(t).isPrimitive() || elemtype(s).isPrimitive()) {
-                        return elemtype(t).tag == elemtype(s).tag;
+                        return elemtype(t).hasTag(elemtype(s).getTag());
                     } else {
                         return visit(elemtype(t), elemtype(s));
                     }
@@ -1527,7 +1536,7 @@
 
             @Override
             public Boolean visitTypeVar(TypeVar t, Type s) {
-                switch (s.tag) {
+                switch (s.getTag()) {
                 case ERROR:
                 case BOT:
                     return true;
@@ -1579,8 +1588,9 @@
 
             private Set<TypePair> cache = new HashSet<TypePair>();
 
+            @Override
             public Boolean visitType(Type t, Type s) {
-                if (s.tag == WILDCARD)
+                if (s.hasTag(WILDCARD))
                     return visit(s, t);
                 else
                     return notSoftSubtypeRecursive(t, s) || notSoftSubtypeRecursive(s, t);
@@ -1617,10 +1627,10 @@
                 if (t.isUnbound())
                     return false;
 
-                if (s.tag != WILDCARD) {
+                if (!s.hasTag(WILDCARD)) {
                     if (t.isExtendsBound())
                         return notSoftSubtypeRecursive(s, t.type);
-                    else // isSuperBound()
+                    else
                         return notSoftSubtypeRecursive(t.type, s);
                 }
 
@@ -1669,21 +1679,21 @@
      */
     public boolean notSoftSubtype(Type t, Type s) {
         if (t == s) return false;
-        if (t.tag == TYPEVAR) {
+        if (t.hasTag(TYPEVAR)) {
             TypeVar tv = (TypeVar) t;
             return !isCastable(tv.bound,
                                relaxBound(s),
                                noWarnings);
         }
-        if (s.tag != WILDCARD)
+        if (!s.hasTag(WILDCARD))
             s = upperBound(s);
 
         return !isSubtype(t, relaxBound(s));
     }
 
     private Type relaxBound(Type t) {
-        if (t.tag == TYPEVAR) {
-            while (t.tag == TYPEVAR)
+        if (t.hasTag(TYPEVAR)) {
+            while (t.hasTag(TYPEVAR))
                 t = t.getUpperBound();
             t = rewriteQuantifiers(t, true, true);
         }
@@ -1732,16 +1742,16 @@
 
     // <editor-fold defaultstate="collapsed" desc="Array Utils">
     public boolean isArray(Type t) {
-        while (t.tag == WILDCARD)
+        while (t.hasTag(WILDCARD))
             t = upperBound(t);
-        return t.tag == ARRAY;
+        return t.hasTag(ARRAY);
     }
 
     /**
      * The element type of an array.
      */
     public Type elemtype(Type t) {
-        switch (t.tag) {
+        switch (t.getTag()) {
         case WILDCARD:
             return elemtype(upperBound(t));
         case ARRAY:
@@ -1775,7 +1785,7 @@
      */
     public int dimensions(Type t) {
         int result = 0;
-        while (t.tag == ARRAY) {
+        while (t.hasTag(ARRAY)) {
             result++;
             t = elemtype(t);
         }
@@ -1789,8 +1799,7 @@
      * @return the ArrayType for the given component
      */
     public ArrayType makeArrayType(Type t) {
-        if (t.tag == VOID ||
-            t.tag == PACKAGE) {
+        if (t.hasTag(VOID) || t.hasTag(PACKAGE)) {
             Assert.error("Type t must not be a VOID or PACKAGE type, " + t.toString());
         }
         return new ArrayType(t, syms.arrayClass);
@@ -1821,7 +1830,7 @@
                     return t;
 
                 Type st = supertype(t);
-                if (st.tag == CLASS || st.tag == TYPEVAR || st.tag == ERROR) {
+                if (st.hasTag(CLASS) || st.hasTag(TYPEVAR) || st.hasTag(ERROR)) {
                     Type x = asSuper(st, sym);
                     if (x != null)
                         return x;
@@ -1863,13 +1872,13 @@
      * @param sym a symbol
      */
     public Type asOuterSuper(Type t, Symbol sym) {
-        switch (t.tag) {
+        switch (t.getTag()) {
         case CLASS:
             do {
                 Type s = asSuper(t, sym);
                 if (s != null) return s;
                 t = t.getEnclosingType();
-            } while (t.tag == CLASS);
+            } while (t.hasTag(CLASS));
             return null;
         case ARRAY:
             return isSubtype(t, sym.type) ? sym.type : null;
@@ -1890,16 +1899,16 @@
      * @param sym a symbol
      */
     public Type asEnclosingSuper(Type t, Symbol sym) {
-        switch (t.tag) {
+        switch (t.getTag()) {
         case CLASS:
             do {
                 Type s = asSuper(t, sym);
                 if (s != null) return s;
                 Type outer = t.getEnclosingType();
-                t = (outer.tag == CLASS) ? outer :
+                t = (outer.hasTag(CLASS)) ? outer :
                     (t.tsym.owner.enclClass() != null) ? t.tsym.owner.enclClass().type :
                     Type.noType;
-            } while (t.tag == CLASS);
+            } while (t.hasTag(CLASS));
             return null;
         case ARRAY:
             return isSubtype(t, sym.type) ? sym.type : null;
@@ -1987,11 +1996,11 @@
      * (not defined for Method and ForAll types)
      */
     public boolean isAssignable(Type t, Type s, Warner warn) {
-        if (t.tag == ERROR)
+        if (t.hasTag(ERROR))
             return true;
-        if (t.tag.isSubRangeOf(INT) && t.constValue() != null) {
+        if (t.getTag().isSubRangeOf(INT) && t.constValue() != null) {
             int value = ((Number)t.constValue()).intValue();
-            switch (s.tag) {
+            switch (s.getTag()) {
             case BYTE:
                 if (Byte.MIN_VALUE <= value && value <= Byte.MAX_VALUE)
                     return true;
@@ -2007,7 +2016,7 @@
             case INT:
                 return true;
             case CLASS:
-                switch (unboxedType(s).tag) {
+                switch (unboxedType(s).getTag()) {
                 case BYTE:
                 case CHAR:
                 case SHORT:
@@ -2135,7 +2144,7 @@
                             null,
                             syms.noSymbol);
         bc.type = new IntersectionClassType(bounds, bc, allInterfaces);
-        bc.erasure_field = (bounds.head.tag == TYPEVAR) ?
+        bc.erasure_field = (bounds.head.hasTag(TYPEVAR)) ?
                 syms.objectType : // error condition, recover
                 erasure(firstExplicitBound);
         bc.members_field = new Scope(bc);
@@ -2198,7 +2207,7 @@
              */
             @Override
             public Type visitTypeVar(TypeVar t, Void ignored) {
-                if (t.bound.tag == TYPEVAR ||
+                if (t.bound.hasTag(TYPEVAR) ||
                     (!t.bound.isCompound() && !t.bound.isInterface())) {
                     return t.bound;
                 } else {
@@ -2502,8 +2511,8 @@
         }
 
         private MethodSymbol implementationInternal(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) {
-            for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = supertype(t)) {
-                while (t.tag == TYPEVAR)
+            for (Type t = origin.type; t.hasTag(CLASS) || t.hasTag(TYPEVAR); t = supertype(t)) {
+                while (t.hasTag(TYPEVAR))
                     t = t.getUpperBound();
                 TypeSymbol c = t.tsym;
                 for (Scope.Entry e = c.members().lookup(ms.name, implFilter);
@@ -2684,13 +2693,13 @@
 
             @Override
             public Boolean visitMethodType(MethodType t, Type s) {
-                return s.tag == METHOD
+                return s.hasTag(METHOD)
                     && containsTypeEquivalent(t.argtypes, s.getParameterTypes());
             }
 
             @Override
             public Boolean visitForAll(ForAll t, Type s) {
-                if (s.tag != FORALL)
+                if (!s.hasTag(FORALL))
                     return strict ? false : visitMethodType(t.asMethodType(), s);
 
                 ForAll forAll = (ForAll)s;
@@ -3025,7 +3034,7 @@
      */
     public int rank(Type t) {
         t = t.unannotatedType();
-        switch(t.tag) {
+        switch(t.getTag()) {
         case CLASS: {
             ClassType cls = (ClassType)t;
             if (cls.rank_field < 0) {
@@ -3091,7 +3100,7 @@
      */
     @Deprecated
     public String toString(Type t) {
-        if (t.tag == FORALL) {
+        if (t.hasTag(FORALL)) {
             ForAll forAll = (ForAll)t;
             return typaramsString(forAll.tvars) + forAll.qtype;
         }
@@ -3157,9 +3166,9 @@
         if (cl == null) {
             Type st = supertype(t);
             if (!t.isCompound()) {
-                if (st.tag == CLASS) {
+                if (st.hasTag(CLASS)) {
                     cl = insert(closure(st), t);
-                } else if (st.tag == TYPEVAR) {
+                } else if (st.hasTag(TYPEVAR)) {
                     cl = closure(st).prepend(t);
                 } else {
                     cl = List.of(t);
@@ -3219,7 +3228,7 @@
         if (isSameType(cl1.head, cl2.head))
             return intersect(cl1.tail, cl2.tail).prepend(cl1.head);
         if (cl1.head.tsym == cl2.head.tsym &&
-            cl1.head.tag == CLASS && cl2.head.tag == CLASS) {
+            cl1.head.hasTag(CLASS) && cl2.head.hasTag(CLASS)) {
             if (cl1.head.isParameterized() && cl2.head.isParameterized()) {
                 Type merge = merge(cl1.head,cl2.head);
                 return intersect(cl1.tail, cl2.tail).prepend(merge);
@@ -3343,7 +3352,7 @@
         final int CLASS_BOUND = 2;
         int boundkind = 0;
         for (Type t : ts) {
-            switch (t.tag) {
+            switch (t.getTag()) {
             case CLASS:
                 boundkind |= CLASS_BOUND;
                 break;
@@ -3353,8 +3362,8 @@
             case  TYPEVAR:
                 do {
                     t = t.getUpperBound();
-                } while (t.tag == TYPEVAR);
-                if (t.tag == ARRAY) {
+                } while (t.hasTag(TYPEVAR));
+                if (t.hasTag(ARRAY)) {
                     boundkind |= ARRAY_BOUND;
                 } else {
                     boundkind |= CLASS_BOUND;
@@ -3394,13 +3403,14 @@
 
         case CLASS_BOUND:
             // calculate lub(A, B)
-            while (ts.head.tag != CLASS && ts.head.tag != TYPEVAR)
+            while (!ts.head.hasTag(CLASS) && !ts.head.hasTag(TYPEVAR)) {
                 ts = ts.tail;
+            }
             Assert.check(!ts.isEmpty());
             //step 1 - compute erased candidate set (EC)
             List<Type> cl = erasedSupertypes(ts.head);
             for (Type t : ts.tail) {
-                if (t.tag == CLASS || t.tag == TYPEVAR)
+                if (t.hasTag(CLASS) || t.hasTag(TYPEVAR))
                     cl = intersect(cl, erasedSupertypes(t));
             }
             //step 2 - compute minimal erased candidate set (MEC)
@@ -3422,7 +3432,7 @@
             // calculate lub(A, B[])
             List<Type> classes = List.of(arraySuperType());
             for (Type t : ts) {
-                if (t.tag != ARRAY) // Filter out any arrays
+                if (!t.hasTag(ARRAY)) // Filter out any arrays
                     classes = classes.prepend(t);
             }
             // lub(A, B[]) is lub(A, arraySuperType)
@@ -3433,7 +3443,7 @@
         List<Type> erasedSupertypes(Type t) {
             ListBuffer<Type> buf = lb();
             for (Type sup : closure(t)) {
-                if (sup.tag == TYPEVAR) {
+                if (sup.hasTag(TYPEVAR)) {
                     buf.append(sup);
                 } else {
                     buf.append(erasure(sup));
@@ -3509,7 +3519,7 @@
         private static final UnaryVisitor<Integer> hashCode = new UnaryVisitor<Integer>() {
 
             public Integer visitType(Type t, Void ignored) {
-                return t.tag.ordinal();
+                return t.getTag().ordinal();
             }
 
             @Override
@@ -3635,7 +3645,7 @@
      * Return the class that boxes the given primitive.
      */
     public ClassSymbol boxedClass(Type t) {
-        return reader.enterClass(syms.boxedName[t.tag.ordinal()]);
+        return reader.enterClass(syms.boxedName[t.getTag().ordinal()]);
     }
 
     /**
@@ -3667,7 +3677,7 @@
      */
     public Type unboxedTypeOrType(Type t) {
         Type unboxedType = unboxedType(t);
-        return unboxedType.tag == NONE ? t : unboxedType;
+        return unboxedType.hasTag(NONE) ? t : unboxedType;
     }
     // </editor-fold>
 
@@ -3717,7 +3727,7 @@
         return buf.reverse();
     }
     public Type capture(Type t) {
-        if (t.tag != CLASS)
+        if (!t.hasTag(CLASS))
             return t;
         if (t.getEnclosingType() != Type.noType) {
             Type capturedEncl = capture(t.getEnclosingType());
@@ -3783,7 +3793,7 @@
         public List<Type> freshTypeVariables(List<Type> types) {
             ListBuffer<Type> result = lb();
             for (Type t : types) {
-                if (t.tag == WILDCARD) {
+                if (t.hasTag(WILDCARD)) {
                     t = t.unannotatedType();
                     Type bound = ((WildcardType)t).getExtendsBound();
                     if (bound == null)
@@ -3953,14 +3963,14 @@
 
         @Override
         public Void visitClassType(ClassType source, Type target) throws AdaptFailure {
-            if (target.tag == CLASS)
+            if (target.hasTag(CLASS))
                 adaptRecursive(source.allparams(), target.allparams());
             return null;
         }
 
         @Override
         public Void visitArrayType(ArrayType source, Type target) throws AdaptFailure {
-            if (target.tag == ARRAY)
+            if (target.hasTag(ARRAY))
                 adaptRecursive(elemtype(source), elemtype(target));
             return null;
         }
@@ -4142,7 +4152,7 @@
         }
 
         Type B(Type t) {
-            while (t.tag == WILDCARD) {
+            while (t.hasTag(WILDCARD)) {
                 WildcardType w = (WildcardType)t.unannotatedType();
                 t = high ?
                     w.getExtendsBound() :
@@ -4187,7 +4197,7 @@
      * substituted by the wildcard
      */
     private WildcardType makeSuperWildcard(Type bound, TypeVar formal) {
-        if (bound.tag == BOT) {
+        if (bound.hasTag(BOT)) {
             return new WildcardType(syms.objectType,
                                     BoundKind.UNBOUND,
                                     syms.boundClass,