< prev index next >

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

Print this page
@@ -31,10 +31,11 @@
  import java.util.Locale;
  import java.util.Map;
  import java.util.Optional;
  import java.util.Set;
  import java.util.WeakHashMap;
+ import java.util.function.BiFunction;
  import java.util.function.BiPredicate;
  import java.util.function.Function;
  import java.util.function.Predicate;
  import java.util.stream.Collector;
  

@@ -47,11 +48,10 @@
  import com.sun.tools.javac.code.TypeMetadata.Annotations;
  import com.sun.tools.javac.comp.AttrContext;
  import com.sun.tools.javac.comp.Check;
  import com.sun.tools.javac.comp.Enter;
  import com.sun.tools.javac.comp.Env;
- import com.sun.tools.javac.comp.LambdaToMethod;
  import com.sun.tools.javac.jvm.ClassFile;
  import com.sun.tools.javac.util.*;
  
  import static com.sun.tools.javac.code.BoundKind.*;
  import static com.sun.tools.javac.code.Flags.*;

@@ -117,11 +117,16 @@
          chk = Check.instance(context);
          enter = Enter.instance(context);
          capturedName = names.fromString("<captured wildcard>");
          messages = JavacMessages.instance(context);
          diags = JCDiagnostic.Factory.instance(context);
-         noWarnings = new Warner(null);
+         noWarnings = new Warner(null) {
+             @Override
+             public String toString() {
+                 return "NO_WARNINGS";
+             }
+         };
      }
      // </editor-fold>
  
      // <editor-fold defaultstate="collapsed" desc="bounds">
      /**

@@ -1680,10 +1685,13 @@
                  if (!pairsSeen.add(newPair))
                      return false;
                  if (isSubtype(erasure(ts.type), erasure(ss.type))) {
                      return false;
                  }
+                 if (isSubtype(erasure(ts.type), erasure(ss.type))) {
+                     return false;
+                 }
                  // if both are classes or both are interfaces, shortcut
                  if (ts.isInterface() == ss.isInterface() && isSubtype(erasure(ss.type), erasure(ts.type))) {
                      return false;
                  }
                  if (ts.isInterface() && !ss.isInterface()) {

@@ -2128,14 +2136,22 @@
       *
       * @param t The component type of the ArrayType
       * @return the ArrayType for the given component
       */
      public ArrayType makeArrayType(Type t) {
+         return makeArrayType(t, 1);
+     }
+ 
+     public ArrayType makeArrayType(Type t, int dimensions) {
          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);
+         ArrayType result = new ArrayType(t, syms.arrayClass);
+         for (int i = 1; i < dimensions; i++) {
+             result = new ArrayType(result, syms.arrayClass);
+         }
+         return result;
      }
      // </editor-fold>
  
      // <editor-fold defaultstate="collapsed" desc="asSuper">
      /**

@@ -2418,11 +2434,11 @@
                          case EXECUTABLE:
                          case NONE:
                          case VOID:
                          case ERROR:
                              return s;
-                         default: return s.dropMetadata(Annotations.class);
+                         default: return s.cloneWithMetadata(t.getMetadata()).dropMetadata(Annotations.class);
                      }
                  } else {
                      return s;
                  }
              }

@@ -3891,11 +3907,11 @@
              }
              Assert.check(act1.isEmpty() && act2.isEmpty() && typarams.isEmpty());
              // There is no spec detailing how type annotations are to
              // be inherited.  So set it to noAnnotations for now
              return new ClassType(class1.getEnclosingType(), merged.toList(),
-                                  class1.tsym);
+                                  class1.tsym, List.nil());
          }
  
      /**
       * Return the minimum type of a closure, a compound type if no
       * unique minimum exists.

@@ -4862,24 +4878,34 @@
       * A wrapper for a type that allows use in sets.
       */
      public static class UniqueType {
          public final Type type;
          final Types types;
+         private boolean encodeTypeSig;
  
-         public UniqueType(Type type, Types types) {
+         public UniqueType(Type type, Types types, boolean encodeTypeSig) {
              this.type = type;
              this.types = types;
+             this.encodeTypeSig = encodeTypeSig;
+         }
+ 
+         public UniqueType(Type type, Types types) {
+             this(type, types, true);
          }
  
          public int hashCode() {
              return types.hashCode(type);
          }
  
          public boolean equals(Object obj) {
              return (obj instanceof UniqueType uniqueType) &&
                      types.isSameType(type, uniqueType.type);
          }
+ 
+         public boolean encodeTypeSig() {
+             return encodeTypeSig;
+         }
  
          public String toString() {
              return type.toString();
          }
  
< prev index next >