8008293: Declared bounds not considered when functional interface containing unbound wildcards is instantiated
Wildcards inference should re-use some of the bounds info generated during capture conversion Reviewed-by: jjg
This commit is contained in:
parent
5bbf5f39fc
commit
8c1621ee38
@ -580,7 +580,17 @@ public class Types {
|
||||
for (Type t : formalInterface.getTypeArguments()) {
|
||||
if (actualTypeargs.head.hasTag(WILDCARD)) {
|
||||
WildcardType wt = (WildcardType)actualTypeargs.head;
|
||||
typeargs.append(wt.type);
|
||||
Type bound;
|
||||
switch (wt.kind) {
|
||||
case UNBOUND:
|
||||
//use declared bound if it doesn't depend on formal type-args
|
||||
bound = wt.bound.bound.containsAny(formalInterface.getTypeArguments()) ?
|
||||
syms.objectType : wt.bound.bound;
|
||||
break;
|
||||
default:
|
||||
bound = wt.type;
|
||||
}
|
||||
typeargs.append(bound);
|
||||
} else {
|
||||
typeargs.append(actualTypeargs.head);
|
||||
}
|
||||
|
41
langtools/test/tools/javac/lambda/TargetType64.java
Normal file
41
langtools/test/tools/javac/lambda/TargetType64.java
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8008293
|
||||
* @summary Declared bounds not considered when functional interface containing unbound wildcards is instantiated
|
||||
* @compile TargetType64.java
|
||||
*/
|
||||
class TargetType64 {
|
||||
interface SAM<X extends Number> {
|
||||
void m(X x);
|
||||
}
|
||||
|
||||
void g(Object o) { }
|
||||
|
||||
void test() {
|
||||
SAM<?> s1 = (x)->{};
|
||||
SAM<?> s2 = this::g;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user