mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-15 16:44:36 +02:00
8078473: javac diamond finder crashes when used to build java.base module
Reviewed-by: mcimadamore
This commit is contained in:
parent
f2ee4e4240
commit
e57ef90dd9
8 changed files with 62 additions and 6 deletions
|
@ -226,8 +226,18 @@ public class Analyzer {
|
|||
@Override
|
||||
void process(JCNewClass oldTree, JCNewClass newTree, boolean hasErrors) {
|
||||
if (!hasErrors) {
|
||||
List<Type> inferredArgs = newTree.type.getTypeArguments();
|
||||
List<Type> explicitArgs = oldTree.type.getTypeArguments();
|
||||
List<Type> inferredArgs, explicitArgs;
|
||||
if (oldTree.def != null) {
|
||||
inferredArgs = newTree.def.implementing.nonEmpty()
|
||||
? newTree.def.implementing.get(0).type.getTypeArguments()
|
||||
: newTree.def.extending.type.getTypeArguments();
|
||||
explicitArgs = oldTree.def.implementing.nonEmpty()
|
||||
? oldTree.def.implementing.get(0).type.getTypeArguments()
|
||||
: oldTree.def.extending.type.getTypeArguments();
|
||||
} else {
|
||||
inferredArgs = newTree.type.getTypeArguments();
|
||||
explicitArgs = oldTree.type.getTypeArguments();
|
||||
}
|
||||
for (Type t : inferredArgs) {
|
||||
if (!types.isSameType(t, explicitArgs.head)) {
|
||||
log.warning(oldTree.clazz, "diamond.redundant.args.1",
|
||||
|
|
|
@ -2006,6 +2006,8 @@ public class Resolve {
|
|||
* @param name The type's name.
|
||||
*/
|
||||
Symbol findType(Env<AttrContext> env, Name name) {
|
||||
if (name == names.empty)
|
||||
return typeNotFound; // do not allow inadvertent "lookup" of anonymous types
|
||||
Symbol bestSoFar = typeNotFound;
|
||||
Symbol sym;
|
||||
boolean staticOnly = false;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2015, 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
|
||||
|
@ -690,7 +690,7 @@ public class TreeMaker implements JCTree.Factory {
|
|||
break;
|
||||
case WILDCARD: {
|
||||
WildcardType a = ((WildcardType) t);
|
||||
tp = Wildcard(TypeBoundKind(a.kind), Type(a.type));
|
||||
tp = Wildcard(TypeBoundKind(a.kind), a.kind == BoundKind.UNBOUND ? null : Type(a.type));
|
||||
break;
|
||||
}
|
||||
case CLASS:
|
||||
|
|
|
@ -3,11 +3,11 @@ T6939780.java:22:28: compiler.warn.diamond.redundant.args
|
|||
T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
|
||||
T6939780.java:24:33: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:25:28: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:26:28: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:26:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
|
||||
T6939780.java:30:19: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:31:19: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:32:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
|
||||
T6939780.java:33:19: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:34:19: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:35:19: compiler.warn.diamond.redundant.args
|
||||
T6939780.java:35:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
|
||||
12 warnings
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8078473
|
||||
* @summary javac diamond finder crashes when used to build java.base module
|
||||
* @compile/ref=T8078473.out T8078473.java -XDrawDiagnostics -XDfind=diamond
|
||||
*/
|
||||
|
||||
class T8078473<P, Q> {
|
||||
|
||||
static class C<T, U> {
|
||||
C(T8078473<?, ?> p) {}
|
||||
}
|
||||
|
||||
{
|
||||
new C<Q, Q>(this) {};
|
||||
new C<Q, Q>(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
T8078473.java:15:14: compiler.warn.diamond.redundant.args.1: T8078473.C<Q,Q>, T8078473.C<java.lang.Object,java.lang.Object>
|
||||
T8078473.java:16:14: compiler.warn.diamond.redundant.args.1: T8078473.C<Q,Q>, T8078473.C<java.lang.Object,java.lang.Object>
|
||||
2 warnings
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8078473
|
||||
* @summary javac diamond finder crashes when used to build java.base module
|
||||
* @compile/ref=T8078473_2.out T8078473_2.java -XDrawDiagnostics -XDfind=diamond
|
||||
*/
|
||||
|
||||
package java.util.stream;
|
||||
|
||||
class T8078473_2<P, Q> {
|
||||
|
||||
static class C<T, U> {
|
||||
C(T8078473_2<?, ?> p) {}
|
||||
}
|
||||
|
||||
{
|
||||
new C<Q, Q>(this) {};
|
||||
new C<Q, Q>(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
T8078473_2.java:17:13: compiler.warn.diamond.redundant.args.1: java.util.stream.T8078473_2.C<Q,Q>, java.util.stream.T8078473_2.C<java.lang.Object,java.lang.Object>
|
||||
T8078473_2.java:18:13: compiler.warn.diamond.redundant.args.1: java.util.stream.T8078473_2.C<Q,Q>, java.util.stream.T8078473_2.C<java.lang.Object,java.lang.Object>
|
||||
2 warnings
|
Loading…
Add table
Add a link
Reference in a new issue