8210483: AssertionError in DeferredAttr at setOverloadKind caused by JDK-8203679

Reviewed-by: mcimadamore, vromero
This commit is contained in:
Liam Miller-Cushon 2018-09-10 16:59:41 -07:00
parent 4e74846da8
commit 7afa8e42b6
5 changed files with 55 additions and 6 deletions

View File

@ -280,8 +280,9 @@ public class ArgumentAttr extends JCTree.Visitor {
if (!res.kind.isResolutionError()) {
tree.sym = res;
}
if (res.kind.isResolutionTargetError() ||
res.type != null && res.type.hasTag(FORALL) ||
if (res.kind.isResolutionTargetError()) {
tree.setOverloadKind(JCMemberReference.OverloadKind.ERROR);
} else if (res.type != null && res.type.hasTag(FORALL) ||
(res.flags() & Flags.VARARGS) != 0 ||
(TreeInfo.isStaticSelector(exprTree, tree.name.table.names) &&
exprTree.type.isRaw() && !exprTree.type.hasTag(ARRAY))) {

View File

@ -169,7 +169,7 @@ public class DeferredAttr extends JCTree.Visitor {
@Override
public void setOverloadKind(OverloadKind overloadKind) {
OverloadKind previous = t.getOverloadKind();
if (previous == null) {
if (previous == null || previous == OverloadKind.ERROR) {
t.setOverloadKind(overloadKind);
} else {
Assert.check(previous == overloadKind);
@ -1240,7 +1240,7 @@ public class DeferredAttr extends JCTree.Visitor {
Type descType = types.findDescriptorType(pt);
List<Type> freeArgVars = inferenceContext.freeVarsIn(descType.getParameterTypes());
if (freeArgVars.nonEmpty() &&
tree.getOverloadKind() == JCMemberReference.OverloadKind.OVERLOADED) {
tree.getOverloadKind() != JCMemberReference.OverloadKind.UNOVERLOADED) {
stuckVars.addAll(freeArgVars);
depVars.addAll(inferenceContext.freeVarsIn(descType.getReturnType()));
}
@ -1305,7 +1305,7 @@ public class DeferredAttr extends JCTree.Visitor {
@Override
public void visitReference(JCMemberReference tree) {
super.visitReference(tree);
if (tree.getOverloadKind() == JCMemberReference.OverloadKind.OVERLOADED) {
if (tree.getOverloadKind() != JCMemberReference.OverloadKind.UNOVERLOADED) {
stuck = true;
}
}

View File

@ -2217,7 +2217,8 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
public enum OverloadKind {
OVERLOADED,
UNOVERLOADED
UNOVERLOADED,
ERROR
}
/**

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2018, Google LLC. 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 8210483
* @summary AssertionError in DeferredAttr at setOverloadKind caused by JDK-8203679
* @compile/fail/ref=MethodRefStuck.out -XDrawDiagnostics MethodRefStuck.java
*/
import java.util.Optional;
import java.util.stream.Stream;
public abstract class MethodRefStuck {
public static void main(Stream<String> xs, Optional<String> x) {
xs.map(
c -> {
return new I(x.map(c::equals));
});
}
static class I {
I(boolean i) {}
}
}

View File

@ -0,0 +1,2 @@
MethodRefStuck.java:38:18: compiler.err.cant.apply.symbol: kindname.constructor, I, boolean, java.util.Optional<java.lang.Boolean>, kindname.class, MethodRefStuck.I, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.instance.exists: U, java.util.Optional<U>, boolean))
1 error