8016880: 42 tests in annot102* fail with compile-time errors.

Tue, 23 Jul 2013 20:42:54 -0400

author
emc
date
Tue, 23 Jul 2013 20:42:54 -0400
changeset 1916
558fe98d1ac0
parent 1915
129751018061
child 1917
2fbe77c38802

8016880: 42 tests in annot102* fail with compile-time errors.
Summary: Fixes error in type equality when bounds of type variables have annotations.
Reviewed-by: jjg, mcimadamore

src/share/classes/com/sun/tools/javac/code/Types.java file | annotate | diff | comparison | revisions
test/tools/javac/annotations/typeAnnotations/ErasureTest.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java	Tue Jul 23 16:06:11 2013 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Tue Jul 23 20:42:54 2013 -0400
     1.3 @@ -134,7 +134,7 @@
     1.4       * @return the upper bound of the given type
     1.5       */
     1.6      public Type upperBound(Type t) {
     1.7 -        return upperBound.visit(t);
     1.8 +        return upperBound.visit(t).unannotatedType();
     1.9      }
    1.10      // where
    1.11          private final MapVisitor<Void> upperBound = new MapVisitor<Void>() {
    1.12 @@ -1130,9 +1130,9 @@
    1.13  
    1.14                      HashSet<UniqueType> set = new HashSet<UniqueType>();
    1.15                      for (Type x : interfaces(t))
    1.16 -                        set.add(new UniqueType(x, Types.this));
    1.17 +                        set.add(new UniqueType(x.unannotatedType(), Types.this));
    1.18                      for (Type x : interfaces(s)) {
    1.19 -                        if (!set.remove(new UniqueType(x, Types.this)))
    1.20 +                        if (!set.remove(new UniqueType(x.unannotatedType(), Types.this)))
    1.21                              return false;
    1.22                      }
    1.23                      return (set.isEmpty());
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/annotations/typeAnnotations/ErasureTest.java	Tue Jul 23 20:42:54 2013 -0400
     2.3 @@ -0,0 +1,51 @@
     2.4 +/*
     2.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.23 + * or visit www.oracle.com if you need additional information or have any
    2.24 + * questions.
    2.25 + */
    2.26 +
    2.27 +/*
    2.28 + * @test
    2.29 + * @bug 8016013
    2.30 + * @summary Compiler incorrectly treats annotated and unannotated type variable bounds as different types
    2.31 + * @compile -doe ErasureTest.java
    2.32 + */
    2.33 +
    2.34 +import java.lang.annotation.ElementType;
    2.35 +import java.lang.annotation.Target;
    2.36 +
    2.37 +@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER })
    2.38 +@interface Advanced {}
    2.39 +
    2.40 +class U {}
    2.41 +interface I {}
    2.42 +
    2.43 +class ErasureTest {
    2.44 +     <T extends U & @Advanced I> void TestMethod(T arg1) { }
    2.45 +    public static void main(String argv[]) {
    2.46 +        ErasureTest t1 = new ErasureTest(){
    2.47 +            public <T extends @Advanced U & I> void TestMethod(T arg1) { }
    2.48 +        };
    2.49 +
    2.50 +        ErasureTest t2 = new ErasureTest(){
    2.51 +            public <T extends U & @Advanced I> void TestMethod(T arg1) { }
    2.52 +        };
    2.53 +    }
    2.54 +}

mercurial