8049075: javac, wildcards and generic vararg method invocation not accepted
Reviewed-by: mcimadamore
This commit is contained in:
parent
12b653bb02
commit
72d5723212
@ -95,7 +95,7 @@ public class Resolve {
|
||||
public final boolean varargsEnabled;
|
||||
public final boolean allowMethodHandles;
|
||||
public final boolean allowFunctionalInterfaceMostSpecific;
|
||||
public final boolean checkVarargsAccessDuringResolution;
|
||||
public final boolean checkVarargsAccessAfterResolution;
|
||||
private final boolean debugResolve;
|
||||
private final boolean compactMethodDiags;
|
||||
final EnumSet<VerboseResolutionMode> verboseResolutionMode;
|
||||
@ -137,7 +137,7 @@ public class Resolve {
|
||||
Target target = Target.instance(context);
|
||||
allowMethodHandles = target.hasMethodHandles();
|
||||
allowFunctionalInterfaceMostSpecific = source.allowFunctionalInterfaceMostSpecific();
|
||||
checkVarargsAccessDuringResolution =
|
||||
checkVarargsAccessAfterResolution =
|
||||
source.allowPostApplicabilityVarargsAccessCheck();
|
||||
polymorphicSignatureScope = new Scope(syms.noSymbol);
|
||||
|
||||
@ -836,13 +836,16 @@ public class Resolve {
|
||||
Warner warn) {
|
||||
super.argumentsAcceptable(env, deferredAttrContext, argtypes, formals, warn);
|
||||
//should we expand formals?
|
||||
if ((!checkVarargsAccessDuringResolution ||
|
||||
(checkVarargsAccessDuringResolution &&
|
||||
deferredAttrContext.mode == AttrMode.CHECK)) &&
|
||||
deferredAttrContext.phase.isVarargsRequired()) {
|
||||
//check varargs element type accessibility
|
||||
varargsAccessible(env, types.elemtype(formals.last()),
|
||||
deferredAttrContext.inferenceContext);
|
||||
if (deferredAttrContext.phase.isVarargsRequired()) {
|
||||
Type typeToCheck = null;
|
||||
if (!checkVarargsAccessAfterResolution) {
|
||||
typeToCheck = types.elemtype(formals.last());
|
||||
} else if (deferredAttrContext.mode == AttrMode.CHECK) {
|
||||
typeToCheck = types.erasure(types.elemtype(formals.last()));
|
||||
}
|
||||
if (typeToCheck != null) {
|
||||
varargsAccessible(env, typeToCheck, deferredAttrContext.inferenceContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 8049075
|
||||
* @summary javac, wildcards and generic vararg method invocation not accepted
|
||||
* @compile VarargsAndWildcardParameterizedTypeTest.java
|
||||
*/
|
||||
|
||||
class VarargsAndWildcardParameterizedTypeTest {
|
||||
interface I<T> {
|
||||
String m(T... t);
|
||||
}
|
||||
|
||||
void m() {
|
||||
I<? super Integer> i = null;
|
||||
i.m(Integer.valueOf(1), Integer.valueOf(1));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user