diff options
author | ssankaran | 2014-10-13 04:46:55 +0000 |
---|---|---|
committer | Jayaprakash Arthanareeswaran | 2014-11-20 05:58:57 +0000 |
commit | 70a316b51979c3bd92082ee446cf065f2f5422e5 (patch) | |
tree | 26803ff8c1ff3a173269b37441997cd6a3c1eac6 | |
parent | fb7f1845c1643d7d5a4c0c8fb22d77f3a2da24b9 (diff) | |
download | eclipse.jdt.core-70a316b51979c3bd92082ee446cf065f2f5422e5.tar.gz eclipse.jdt.core-70a316b51979c3bd92082ee446cf065f2f5422e5.tar.xz eclipse.jdt.core-70a316b51979c3bd92082ee446cf065f2f5422e5.zip |
Fixed Bug 446715 - [compiler]
org.eclipse.jdt.internal.compiler.lookup.TypeSystem.cacheDerivedType
2 files changed, 40 insertions, 0 deletions
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 057cb7dbfe..d0239624c8 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 @@ -5930,4 +5930,40 @@ public void test445669() { "Null type mismatch: required \'@NonNull Z\' but the provided value is null\n" + "----------\n"); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=446715, [compiler] org.eclipse.jdt.internal.compiler.lookup.TypeSystem.cacheDerivedType +public void test446715() { + Map options = getCompilerOptions(); + runConformTestWithLibs( + new String[] { + "Y.java", + "import org.eclipse.jdt.annotation.NonNull;\n" + + "public class Y {\n" + + " public Z.ZI @NonNull [] zz = new Z.ZI[0];\n" + + "}\n", + "Z.java", + "public class Z {\n" + + " public class ZI {\n" + + " }\n" + + "}\n" + }, + options, + ""); + runNegativeTestWithLibs( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " Y y = new Y();\n" + + " y.zz = null;\n" + + " }\n" + + "}\n" + }, + options, + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " y.zz = null;\n" + + " ^^^^\n" + + "Null type mismatch: required \'Z.ZI @NonNull[]\' but the provided value is null\n" + + "----------\n"); +} } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java index 224f05b51b..9190ca0da1 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java @@ -156,7 +156,9 @@ public class TypeSystem { // Given a type, answer its unannotated aka naked prototype. This is also a convenient way to "register" a type with TypeSystem and have it id stamped. public final TypeBinding getUnannotatedType(TypeBinding type) { + UnresolvedReferenceBinding urb = null; if (type.isUnresolvedType() && CharOperation.indexOf('$', type.sourceName()) > 0) { + urb = (UnresolvedReferenceBinding) type; boolean mayTolerateMissingType = this.environment.mayTolerateMissingType; this.environment.mayTolerateMissingType = true; try { @@ -172,6 +174,8 @@ public class TypeSystem { if (this.typeid == typesLength) System.arraycopy(this.types, 0, this.types = new TypeBinding[typesLength * 2][], 0, typesLength); this.types[type.id = this.typeid++] = new TypeBinding[4]; + if (urb != null) + urb.id = type.id; } else { TypeBinding nakedType = this.types[type.id] == null ? null : this.types[type.id][0]; if (type.hasTypeAnnotations() && nakedType == null) |