src/share/classes/com/sun/tools/javac/code/Types.java

changeset 1521
71f35e4b93a5
parent 1510
7873d37f5b37
child 1550
1df20330f6bd
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java	Wed Jan 23 20:57:40 2013 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Wed Jan 23 13:27:24 2013 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -34,13 +34,14 @@
    1.11  import java.util.Set;
    1.12  import java.util.WeakHashMap;
    1.13  
    1.14 +import javax.lang.model.type.TypeKind;
    1.15 +
    1.16  import com.sun.tools.javac.code.Attribute.RetentionPolicy;
    1.17  import com.sun.tools.javac.code.Lint.LintCategory;
    1.18  import com.sun.tools.javac.code.Type.UndetVar.InferenceBound;
    1.19  import com.sun.tools.javac.comp.Check;
    1.20  import com.sun.tools.javac.jvm.ClassReader;
    1.21  import com.sun.tools.javac.util.*;
    1.22 -import com.sun.tools.javac.util.List;
    1.23  import static com.sun.tools.javac.code.BoundKind.*;
    1.24  import static com.sun.tools.javac.code.Flags.*;
    1.25  import static com.sun.tools.javac.code.Scope.*;
    1.26 @@ -684,6 +685,8 @@
    1.27      //where
    1.28          private boolean isSubtypeUncheckedInternal(Type t, Type s, Warner warn) {
    1.29              if (t.hasTag(ARRAY) && s.hasTag(ARRAY)) {
    1.30 +                t = t.unannotatedType();
    1.31 +                s = s.unannotatedType();
    1.32                  if (((ArrayType)t).elemtype.isPrimitive()) {
    1.33                      return isSameType(elemtype(t), elemtype(s));
    1.34                  } else {
    1.35 @@ -709,7 +712,10 @@
    1.36          }
    1.37  
    1.38          private void checkUnsafeVarargsConversion(Type t, Type s, Warner warn) {
    1.39 -            if (t.tag != ARRAY || isReifiable(t)) return;
    1.40 +            if (t.tag != ARRAY || isReifiable(t))
    1.41 +                return;
    1.42 +            t = t.unannotatedType();
    1.43 +            s = s.unannotatedType();
    1.44              ArrayType from = (ArrayType)t;
    1.45              boolean shouldWarn = false;
    1.46              switch (s.tag) {
    1.47 @@ -742,6 +748,12 @@
    1.48          if (t == s)
    1.49              return true;
    1.50  
    1.51 +        t = t.unannotatedType();
    1.52 +        s = s.unannotatedType();
    1.53 +
    1.54 +        if (t == s)
    1.55 +            return true;
    1.56 +
    1.57          if (s.isPartial())
    1.58              return isSuperType(s, t);
    1.59  
    1.60 @@ -1683,6 +1695,7 @@
    1.61          case WILDCARD:
    1.62              return elemtype(upperBound(t));
    1.63          case ARRAY:
    1.64 +            t = t.unannotatedType();
    1.65              return ((ArrayType)t).elemtype;
    1.66          case FORALL:
    1.67              return elemtype(((ForAll)t).qtype);
    1.68 @@ -2011,6 +2024,11 @@
    1.69              public Type visitErrorType(ErrorType t, Boolean recurse) {
    1.70                  return t;
    1.71              }
    1.72 +
    1.73 +            @Override
    1.74 +            public Type visitAnnotatedType(AnnotatedType t, Boolean recurse) {
    1.75 +                return new AnnotatedType(t.typeAnnotations, erasure(t.underlyingType, recurse));
    1.76 +            }
    1.77          };
    1.78  
    1.79      private Mapping erasureFun = new Mapping ("erasure") {
    1.80 @@ -2953,6 +2971,7 @@
    1.81       * graph. Undefined for all but reference types.
    1.82       */
    1.83      public int rank(Type t) {
    1.84 +        t = t.unannotatedType();
    1.85          switch(t.tag) {
    1.86          case CLASS: {
    1.87              ClassType cls = (ClassType)t;
    1.88 @@ -3654,6 +3673,7 @@
    1.89                  t = subst(type1, t.tsym.type.getTypeArguments(), t.getTypeArguments());
    1.90              }
    1.91          }
    1.92 +        t = t.unannotatedType();
    1.93          ClassType cls = (ClassType)t;
    1.94          if (cls.isRaw() || !cls.isParameterized())
    1.95              return cls;
    1.96 @@ -4172,6 +4192,8 @@
    1.97          public R visitForAll(ForAll t, S s)             { return visitType(t, s); }
    1.98          public R visitUndetVar(UndetVar t, S s)         { return visitType(t, s); }
    1.99          public R visitErrorType(ErrorType t, S s)       { return visitType(t, s); }
   1.100 +        // Pretend annotations don't exist
   1.101 +        public R visitAnnotatedType(AnnotatedType t, S s) { return visit(t.underlyingType, s); }
   1.102      }
   1.103  
   1.104      /**

mercurial