1 /* 2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 8191802 27 * @summary Upward projection result is A<? extends Number> instead of A<? super Integer> 28 * @modules jdk.compiler/com.sun.source.tree 29 * jdk.compiler/com.sun.source.util 30 * jdk.compiler/com.sun.tools.javac.api 31 * jdk.compiler/com.sun.tools.javac.code 32 * jdk.compiler/com.sun.tools.javac.util 33 * @build LocalVariableInferenceTester 34 * @run main LocalVariableInferenceTester UpperBounds.java 35 */ 36 class UpperBounds { 37 38 static class A<T extends Number> { } 39 40 static class C<T extends Comparable<T>> { } 41 test1(A<? super Integer> s)42 void test1(A<? super Integer> s) { 43 //U is not Object, Bi is not fbound and U is not more specific than Bi, use "? super L" 44 @InferredType("UpperBounds.A<? super java.lang.Integer>") 45 var x = s; 46 } 47 test2(C<? super Integer> s)48 void test2(C<? super Integer> s) { 49 //U is not Object, Bi is fbound, use "? extends L" 50 @InferredType("UpperBounds.C<? extends java.lang.Comparable<?>>") 51 var x = s; 52 } 53 test3(A<? extends Object> s)54 void test3(A<? extends Object> s) { 55 //U is not Object, Bi is not fbound and U is not more specific than Bi, L is undefined, use "?" 56 @InferredType("UpperBounds.A<?>") 57 var x = s; 58 } 59 test4(A<? extends Integer> s)60 void test4(A<? extends Integer> s) { 61 //U is not Object, Bi is not fbound and U is more specific than Bi, use "? extends U" 62 @InferredType("UpperBounds.A<? extends java.lang.Integer>") 63 var x = s; 64 } 65 test5(A<? extends Object> s)66 void test5(A<? extends Object> s) { 67 //U is not Object, Bi is not fbound and U is not more specific than Bi, L is undefined, use "?" 68 @InferredType("UpperBounds.A<?>") 69 var x = s; 70 } 71 } 72