Skip to content

Commit

Permalink
clean-up and fix regression:
Browse files Browse the repository at this point in the history
+ revert duplicate tagging with HasMissingType (already in initialize())
+ fix tests by adding required import
+ create one test variant with missing import and POTENTIAL_MATCH
  • Loading branch information
stephan-herrmann committed Jul 11, 2024
1 parent 1b4526a commit 82ee42d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ public ParameterizedTypeBinding(ReferenceBinding type, TypeBinding[] arguments,
for (TypeBinding argument : arguments) {
if (argument instanceof UnresolvedReferenceBinding)
((UnresolvedReferenceBinding) argument).addWrapper(this, environment);
this.tagBits |= argument.tagBits & (TagBits.HasNullTypeAnnotation | TagBits.HasMissingType);
if (argument.hasNullTypeAnnotations())
this.tagBits |= TagBits.HasNullTypeAnnotation;
}
}
if (enclosingType != null)
this.tagBits |= enclosingType.tagBits & (TagBits.HasNullTypeAnnotation | TagBits.HasMissingType);
if (enclosingType != null && enclosingType.hasNullTypeAnnotations())
this.tagBits |= TagBits.HasNullTypeAnnotation;
this.tagBits |= TagBits.HasUnresolvedTypeVariables; // cleared in resolve()
this.typeBits = type.typeBits;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014, 2016 IBM Corporation and others.
* Copyright (c) 2014, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -210,6 +210,7 @@ public void testBug123836c() throws CoreException {
// create the common project and create an interface
project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5");
createFile("/P/Test.java",
"import java.io.Serializable;\n" +
"class Test {\n"+
" void calc(Property prop, Property<? extends Serializable> p2) {\n"+
" prop.compute(null);\n"+
Expand All @@ -232,6 +233,36 @@ public void testBug123836c() throws CoreException {
deleteProject(project);
}
}
public void testBug123836c_missingImport() throws CoreException {
// original version with missing import, will now give POTENTIAL_MATCH
IJavaProject project = null;
try
{
// create the common project and create an interface
project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5");
createFile("/P/Test.java",
"class Test {\n"+
" void calc(Property prop, Property<? extends Serializable> p2) {\n"+
" prop.compute(null);\n"+
" p2.compute(null);\n"+
" }\n"+
"}\n"+
"abstract class Property<E> {\n"+
" public abstract void compute(E e);\n"+
"}\n"+
"class StringProperty extends Property<String> {\n"+
" @Override public void compute(String e) {\n"+
" System.out.println(e);\n"+
" }");
IType type = getCompilationUnit("/P/Test.java").getType("StringProperty");
IMethod method = type.getMethod("compute", new String[]{"QString;"});
search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector);
assertSearchResults("Test.java void Test.calc(Property, Property<? extends Serializable>) [compute(null)] EXACT_MATCH\n" +
"Test.java void Test.calc(Property, Property<? extends Serializable>) [compute(null)] POTENTIAL_MATCH");
} finally {
deleteProject(project);
}
}
// Test inner class
public void testBug123836d() throws CoreException {
IJavaProject project = null;
Expand All @@ -240,6 +271,7 @@ public void testBug123836d() throws CoreException {
// create the common project and create an interface
project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5");
createFile("/P/Test.java",
"import java.io.Serializable;\n" +
"class Test {\n"+
" void calc(Property prop, Property<? extends Serializable> p2) {\n"+
" prop.compute(null);\n"+
Expand Down Expand Up @@ -271,6 +303,7 @@ public void testBug123836e() throws CoreException {
// create the common project and create an interface
project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5");
createFile("/P/Test.java",
"import java.io.Serializable;\n" +
"class Test {\n"+
" void calc(Property prop, Property<? extends Serializable> p2) {\n"+
" prop.compute(null);\n"+
Expand Down Expand Up @@ -301,6 +334,7 @@ public void testBug123836f() throws CoreException {
// create the common project and create an interface
project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5");
createFile("/P/Test.java",
"import java.io.Serializable;\n" +
"class Test {\n"+
" void calc(Property prop, Property<? extends Serializable> p2) {\n"+
" prop.compute(null);\n"+
Expand Down Expand Up @@ -331,6 +365,7 @@ public void testBug123836g() throws CoreException {
// create the common project and create an interface
project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5");
createFile("/P/Test.java",
"import java.io.Serializable;\n" +
"class Test {\n"+
" {\n" +
" new Property<String>() {\n" +
Expand Down Expand Up @@ -361,6 +396,7 @@ public void testBug123836h() throws CoreException {
// create the common project and create an interface
project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5");
createFile("/P/Test.java",
"import java.io.Serializable;\n" +
"class Test {\n"+
" static {\n" +
" new Property<String>() {\n" +
Expand Down Expand Up @@ -391,6 +427,7 @@ public void testBug123836i() throws CoreException {
// create the common project and create an interface
project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5");
createFile("/P/Test.java",
"import java.io.Serializable;\n" +
"class Test {\n"+
" Property <?>p = new Property<String>() {\n" +
" @Override public void compute(String e) {}\n" +
Expand Down Expand Up @@ -418,6 +455,7 @@ public void testBug123836j() throws CoreException {
// create the common project and create an interface
project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "","1.5");
createFile("/P/Test.java",
"import java.io.Serializable;\n" +
"class Test {\n"+
" void calc(Property prop, Property<? extends Serializable> p2) {\n"+
" prop.compute(null);\n"+
Expand Down

0 comments on commit 82ee42d

Please sign in to comment.