Bug 467032 - TYPE_USE Null Annotations: IllegalStateException with
annotated arrays of Enum when accessed via BinaryTypeBinding

Change-Id: Ibc459463f46502387454d28652cd1fe8c8424a39
Signed-off-by: Stephan Herrmann <stephan.herrmann@berlin.de>
Also-by: Till Brychcy <register.eclipse@brychcy.de>
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
index 2959dbf..3c2415c 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
@@ -8,6 +8,8 @@
  * Contributors:

  *     Stephan Herrmann - initial API and implementation

  *     IBM Corporation

+ *     Till Brychcy - Contribution for

+ *								Bug 467032 - TYPE_USE Null Annotations: IllegalStateException with annotated arrays of Enum when accessed via BinaryTypeBinding

  *******************************************************************************/

 package org.eclipse.jdt.core.tests.compiler.regression;

 

@@ -8083,4 +8085,21 @@
 		"Nullness annotations are not applicable at this location \n" + 

 		"----------\n");

 }

+public void testBug467032() {

+	runConformTestWithLibs(

+			new String[] {

+				"Class1.java",

+				"class Class1 {;\n"+

+				"   enum E {}\n"+

+				"   void m1(E @org.eclipse.jdt.annotation.Nullable [] a) {}\n"+

+				"}\n"

+			}, getCompilerOptions(), "");

+	runConformTestWithLibs(

+			new String[] {

+				"Class2.java",

+				"class Class2 {;\n"+

+				"  Class1 x;"+

+				"}\n"

+			}, getCompilerOptions(), "");

+}

 }

diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java
index ce4f3d8..e15f29a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java
@@ -11,6 +11,7 @@
  *								bug 349326 - [1.7] new warning for missing try-with-resources
  *								bug 392384 - [1.8][compiler][null] Restore nullness info from type annotations in class files
  *								Bug 392099 - [1.8][compiler][null] Apply null annotation on types for null analysis
+ *								Bug 467032 - TYPE_USE Null Annotations: IllegalStateException with annotated arrays of Enum when accessed via BinaryTypeBinding
  *******************************************************************************/
 package org.eclipse.jdt.internal.compiler.lookup;
 
@@ -109,6 +110,9 @@
 			// create a proxy for the missing BinaryType
 			targetType = environment.createMissingType(null, this.compoundName);
 		}
+		if (targetType.id != TypeIds.NoId) {
+			this.id = targetType.id;
+		}
 		setResolvedType(targetType, environment);
 	}
 	if (convertGenericToRawType) {