Skip to content

Commit ca37a48

Browse files
committed
8334757: AssertionError: Missing type variable in where clause
Reviewed-by: jlahoda, vromero Backport-of: babf6df
1 parent ae10055 commit ca37a48

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/jdk.compiler/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ protected void preprocessArgument(Object arg) {
184184
if (arg instanceof Type type) {
185185
preprocessType(type);
186186
}
187+
else if (arg instanceof JCDiagnostic.AnnotatedType type) {
188+
preprocessType(type.type());
189+
}
187190
else if (arg instanceof Symbol symbol) {
188191
preprocessSymbol(symbol);
189192
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* @test /nodynamiccopyright/
3+
* @bug 8334757
4+
* @compile/fail/ref=CantAnnotateClassWithTypeVariable.out -XDrawDiagnostics CantAnnotateClassWithTypeVariable.java
5+
*/
6+
7+
import java.lang.annotation.ElementType;
8+
import java.lang.annotation.Target;
9+
10+
public class CantAnnotateClassWithTypeVariable {
11+
@Target(ElementType.TYPE_USE)
12+
@interface TA {}
13+
14+
static class A {
15+
static class B<T> {}
16+
}
17+
18+
<T> @TA A.B<T> f() {}
19+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CantAnnotateClassWithTypeVariable.java:18:14: compiler.err.type.annotation.inadmissible: (compiler.misc.type.annotation.1: @CantAnnotateClassWithTypeVariable.TA), CantAnnotateClassWithTypeVariable.A, @CantAnnotateClassWithTypeVariable.TA CantAnnotateClassWithTypeVariable.A.B<T>
2+
1 error

0 commit comments

Comments
 (0)