File tree Expand file tree Collapse file tree
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -942,7 +942,7 @@ private VariableBinding resolveTypeFor(VariableBinding variable) {
942942 return this .prototype .resolveTypeFor (variable );
943943
944944 if ((variable .modifiers & ExtraCompilerModifiers .AccUnresolved ) == 0 )
945- return variable ;
945+ return variable . type == null ? null : variable ; // don't allow a prior resolution error to be masked.
946946
947947 MethodScope initializationScope = variable .isStatic ()
948948 ? this .scope .referenceContext .staticInitializerScope
Original file line number Diff line number Diff line change @@ -13440,4 +13440,47 @@ public void run() {
1344013440 "1 problem (1 error)\n " ,
1344113441 true );
1344213442}
13443+ // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4768
13444+ // Internal Compiler Error when a static field with custom annotation references a generic type parameter T
13445+ public void testIssue4768 (){
13446+ this .runNegativeTest (
13447+ new String [] {
13448+ "X.java" ,
13449+ """
13450+ import java.lang.annotation.*;
13451+ @interface CompileTimeConstant {}
13452+
13453+ class FunctionPointerContainer<T> {
13454+ @CompileTimeConstant
13455+ public static final T VALUE = null;
13456+ }
13457+
13458+ public class X {
13459+ public static void main(String[] args) {
13460+ FunctionPointerContainer<Integer> nestedContainer = new FunctionPointerContainer<>();
13461+ Integer value = nestedContainer.VALUE;
13462+ }
13463+ }
13464+ """ ,
13465+ },
13466+
13467+ "\" " + OUTPUT_DIR + File .separator + "X.java\" "
13468+ + " -sourcepath \" " + OUTPUT_DIR + "\" "
13469+ + " -nowarn -d \" " + OUTPUT_DIR + "\" " ,
13470+ "" ,
13471+ "----------\n " +
13472+ "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 6)\n " +
13473+ " public static final T VALUE = null;\n " +
13474+ " ^\n " +
13475+ "Cannot make a static reference to the non-static type T\n " +
13476+ "----------\n " +
13477+ "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 12)\n " +
13478+ " Integer value = nestedContainer.VALUE;\n " +
13479+ " ^^^^^\n " +
13480+ "VALUE cannot be resolved or is not a field\n " +
13481+ "----------\n " +
13482+ "2 problems (2 errors)\n " ,
13483+
13484+ true );
13485+ }
1344313486}
You can’t perform that action at this time.
0 commit comments