Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2020-01-15 22:12:07 +0000
committerStephan Herrmann2020-01-15 22:12:07 +0000
commit9eac2d764cbec2160db1c91a3a05341846688165 (patch)
tree84d9d46a416375b51e78f3d3c50bc61002e69eb6
parentd5bebfcd41e40e691236ae672f0c877a727409c1 (diff)
downloadeclipse.jdt.core-9eac2d764cbec2160db1c91a3a05341846688165.tar.gz
eclipse.jdt.core-9eac2d764cbec2160db1c91a3a05341846688165.tar.xz
eclipse.jdt.core-9eac2d764cbec2160db1c91a3a05341846688165.zip
SourceTypeBinding.hasMethodWithNumArgs Change-Id: I7f69654dbd633a6559dab38019b99ad5684e5a0e
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java58
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java2
2 files changed, 59 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java
index 4a8587c514..b12283be76 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java
@@ -3262,4 +3262,62 @@ public void testBug425111() throws Exception {
if (javaProject1 != null) deleteProject(javaProject1);
}
}
+public void testBug559210() throws CoreException {
+ try {
+ createJavaProject("P", new String[] {"src"}, new String[] {"JCL_LIB", "lib"}, "bin", "1.7");
+ createFolder("/P/src/java/io");
+ createFile(
+ "/P/src/java/io/Closeable.java",
+ "pakage java.io;\n" +
+ "public interface Closeable { void close(); }\n");
+ createFile(
+ "/P/src/java/io/InputStream.java",
+ "pakage java.io;\n" +
+ "public abstract class InputStream implements Closeable { }\n");
+
+ createFolder("/P/src/p");
+ createFile(
+ "/P/src/p/ReferenceInputStream.java",
+ "pakage p;\n" +
+ "public class ReferenceInputStream extends java.io.InputStream {\n" +
+ " private final File reference;\n" +
+ "\n" +
+ " public ReferenceInputStream(File reference) {\n" +
+ " this.reference = reference;\n" +
+ " }\n" +
+ "\n" +
+ " /* This method should not be called.\n" +
+ " */\n" +
+ " @Override\n" +
+ " public int read() throws IOException {\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ "\n" +
+ " public File getReference() {\n" +
+ " return reference;\n" +
+ " }\n" +
+ "}"
+ );
+ createFile(
+ "/P/src/p/Storage.java",
+ "pakage p;\n" +
+ "import p.ReferenceInputStream;\n" +
+ "public class Storage {\n" +
+ "\n" +
+ " public ReferenceInputStream stream;\n" +
+ "}"
+ );
+ getProject("P").build(IncrementalProjectBuilder.FULL_BUILD, null);
+ waitForAutoBuild();
+ ITypeHierarchy hierarchy = getCompilationUnit("/P/src/p/Storage.java").getTypes()[0].newSupertypeHierarchy(null);
+ assertHierarchyEquals(
+ "Focus: Storage [in Storage.java [in p [in src [in P]]]]\n" +
+ "Super types:\n" +
+ " Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + "]]]\n" +
+ "Sub types:\n",
+ hierarchy);
+ } finally {
+ deleteProject("P");
+ }
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
index a8f9b01261..1346665326 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
@@ -2272,7 +2272,7 @@ protected boolean hasMethodWithNumArgs(char[] selector, int numArgs) {
if ((this.tagBits & TagBits.AreMethodsComplete) != 0)
return super.hasMethodWithNumArgs(selector, numArgs);
// otherwise don't trigger unResolvedMethods() which would actually resolve!
- if (this.scope != null) {
+ if (this.scope != null && this.scope.referenceContext.methods != null) {
for (AbstractMethodDeclaration method : this.scope.referenceContext.methods) {
if (CharOperation.equals(method.selector, TypeConstants.CLOSE)) {
if (numArgs == 0) {

Back to the top