diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java index 986755e..4be62b1 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java @@ -7111,4 +7111,81 @@ compilerOptions /* custom options */ ); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=360164 +public void test360164() { + if (this.complianceLevel < ClassFileConstants.JDK1_5) return; + this.runConformTest( + new String[] { + "p/B.java", + "package p;\n" + + "\n" + + "public abstract class B {\n" + + " protected abstract V foo(K element);\n" + + "}\n", + "p/C.java", + "package p;\n" + + "public class C {\n" + + "}\n", + "p/D.java", + "package p;\n" + + "public class D extends E {\n" + + "}\n", + "p/E.java", + "package p;\n" + + "public abstract class E implements I {\n" + + "}\n", + "p/I.java", + "package p;\n" + + "public interface I {\n" + + "}\n", + "p/X.java", + "package p;\n" + + "public class X {\n" + + " private final class A extends B{\n" + + " @Override\n" + + " protected D foo(C c) {\n" + + " return null;\n" + + " }\n" + + " }\n" + + "}\n", + }, + ""); + + // delete binary file Zork (i.e. simulate removing it from classpath for subsequent compile) + Util.delete(new File(OUTPUT_DIR, "p" + File.separator + "I.class")); + + runNegativeTest( + // test directory preparation + false /* do not flush output directory */, + new String[] { /* test files */ + "p/X.java", + "package p;\n" + + "public class X {\n" + + " private final class A extends B{\n" + + " @Override\n" + + " protected D foo(C c) {\n" + + " Zork z;\n" + + " return null;\n" + + " }\n" + + " }\n" + + "}\n", + }, + // compiler options + null /* no class libraries */, + null /* no custom options */, + // compiler results + "----------\n" + + "1. WARNING in p\\X.java (at line 3)\n" + + " private final class A extends B{\n" + + " ^\n" + + "The type X.A is never used locally\n" + + "----------\n" + + "2. ERROR in p\\X.java (at line 6)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + + "----------\n", + // javac options + JavacTestOptions.SKIP_UNTIL_FRAMEWORK_FIX /* javac test options */); +} } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java index 8a84619..b8581e3 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java @@ -1157,8 +1157,14 @@ this.tagBits |= TagBits.HierarchyHasProblems; // propagate type inconsistency } else { // make super-type resolving recursive for propagating typeBits downwards - this.superclass.superclass(); - this.superclass.superInterfaces(); + boolean wasToleratingMissingTypeProcessingAnnotations = this.environment.mayTolerateMissingType; + this.environment.mayTolerateMissingType = true; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=360164 + try { + this.superclass.superclass(); + this.superclass.superInterfaces(); + } finally { + this.environment.mayTolerateMissingType = wasToleratingMissingTypeProcessingAnnotations; + } } this.typeBits |= this.superclass.typeBits; return this.superclass; @@ -1174,8 +1180,14 @@ this.tagBits |= TagBits.HierarchyHasProblems; // propagate type inconsistency } else { // make super-type resolving recursive for propagating typeBits downwards - this.superInterfaces[i].superclass(); - this.superInterfaces[i].superInterfaces(); + boolean wasToleratingMissingTypeProcessingAnnotations = this.environment.mayTolerateMissingType; + this.environment.mayTolerateMissingType = true; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=360164 + try { + this.superInterfaces[i].superclass(); + this.superInterfaces[i].superInterfaces(); + } finally { + this.environment.mayTolerateMissingType = wasToleratingMissingTypeProcessingAnnotations; + } } this.typeBits |= this.superInterfaces[i].typeBits; }