mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-19 18:44:38 +02:00
8052070: javac crashes when there are duplicated type parameters
Avoid eager completion of ClassSymbol while type parameters are being processed. Reviewed-by: jlahoda, mcimadamore
This commit is contained in:
parent
ca4dba303f
commit
671f90ddc7
3 changed files with 24 additions and 1 deletions
|
@ -385,7 +385,7 @@ public class Enter extends JCTree.Visitor {
|
|||
typeEnvs.put(c, localEnv);
|
||||
|
||||
// Fill out class fields.
|
||||
c.completer = typeEnter;
|
||||
c.completer = null; // do not allow the initial completer linger on.
|
||||
c.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, c, tree);
|
||||
c.sourcefile = env.toplevel.sourcefile;
|
||||
c.members_field = WriteableScope.create(c);
|
||||
|
@ -409,6 +409,9 @@ public class Enter extends JCTree.Visitor {
|
|||
// Enter type parameters.
|
||||
ct.typarams_field = classEnter(tree.typarams, localEnv);
|
||||
|
||||
// install further completer for this type.
|
||||
c.completer = typeEnter;
|
||||
|
||||
// Add non-local class to uncompleted, to make sure it will be
|
||||
// completed later.
|
||||
if (!c.isLocal() && uncompleted != null) uncompleted.append(c);
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8052070
|
||||
* @summary javac crashes when there are duplicated type parameters
|
||||
* @compile/fail/ref=DuplicateTypeParameter.out -XDrawDiagnostics DuplicateTypeParameter.java
|
||||
*/
|
||||
|
||||
public class DuplicateTypeParameter<T, T, A> {
|
||||
class Inner <P, P, Q> {}
|
||||
public void foo() {
|
||||
class Local <M, M, N> {};
|
||||
}
|
||||
}
|
||||
|
||||
class Secondary<D, D, E> {}
|
|
@ -0,0 +1,5 @@
|
|||
DuplicateTypeParameter.java:8:40: compiler.err.already.defined: kindname.type.variable, T, kindname.class, DuplicateTypeParameter
|
||||
DuplicateTypeParameter.java:9:21: compiler.err.already.defined: kindname.type.variable, P, kindname.class, DuplicateTypeParameter.Inner
|
||||
DuplicateTypeParameter.java:15:20: compiler.err.already.defined: kindname.type.variable, D, kindname.class, Secondary
|
||||
DuplicateTypeParameter.java:11:25: compiler.err.already.defined: kindname.type.variable, M, kindname.class, Local
|
||||
4 errors
|
Loading…
Add table
Add a link
Reference in a new issue