View | Details | Raw Unified | Return to bug 221110 | Differences between
and this patch

Collapse All | Expand All

(-)search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java (-10 / +14 lines)
Lines 2575-2585 Link Here
2575
							}
2575
							}
2576
							if (typeArgument instanceof Wildcard) {
2576
							if (typeArgument instanceof Wildcard) {
2577
	                            TypeReference wildcardBound = ((Wildcard) typeArgument).bound;
2577
	                            TypeReference wildcardBound = ((Wildcard) typeArgument).bound;
2578
								level = (Integer) nodeSet.matchingNodes.removeKey(wildcardBound);
2578
	                            if (wildcardBound != null) {
2579
								if (level != null) {
2579
									level = (Integer) nodeSet.matchingNodes.removeKey(wildcardBound);
2580
									IJavaElement localElement = createHandle(typeParameter, enclosingElement);
2580
									if (level != null) {
2581
									this.patternLocator.matchReportReference(wildcardBound, enclosingElement, localElement, null, binding, level.intValue(), this);
2581
										IJavaElement localElement = createHandle(typeParameter, enclosingElement);
2582
								}
2582
										this.patternLocator.matchReportReference(wildcardBound, enclosingElement, localElement, null, binding, level.intValue(), this);
2583
									}
2584
	                            }
2583
                            }
2585
                            }
2584
                    	}
2586
                    	}
2585
                    }
2587
                    }
Lines 2606-2616 Link Here
2606
								}
2608
								}
2607
								if (typeArgument instanceof Wildcard) {
2609
								if (typeArgument instanceof Wildcard) {
2608
		                            TypeReference wildcardBound = ((Wildcard) typeArgument).bound;
2610
		                            TypeReference wildcardBound = ((Wildcard) typeArgument).bound;
2609
									level = (Integer) nodeSet.matchingNodes.removeKey(wildcardBound);
2611
		                            if (wildcardBound != null) {
2610
									if (level != null) {
2612
										level = (Integer) nodeSet.matchingNodes.removeKey(wildcardBound);
2611
										IJavaElement localElement = createHandle(typeParameter, enclosingElement);
2613
										if (level != null) {
2612
										this.patternLocator.matchReportReference(wildcardBound, enclosingElement, localElement, null, binding, level.intValue(), this);
2614
											IJavaElement localElement = createHandle(typeParameter, enclosingElement);
2613
									}
2615
											this.patternLocator.matchReportReference(wildcardBound, enclosingElement, localElement, null, binding, level.intValue(), this);
2616
										}
2617
		                            }
2614
	                            }
2618
	                            }
2615
	                    	}
2619
	                    	}
2616
	                    }
2620
	                    }
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (+47 lines)
Lines 9743-9746 Link Here
9743
		"src/Bug.java Bug.{}:Inner#1.field [			§|Row|§ field;//LINE 3] EXACT_MATCH"
9743
		"src/Bug.java Bug.{}:Inner#1.field [			§|Row|§ field;//LINE 3] EXACT_MATCH"
9744
	);
9744
	);
9745
}
9745
}
9746
9747
/**
9748
 * @bug 221110: [search] NPE at org.eclipse.jdt.internal.compiler.util.SimpleLookupTable.removeKey
9749
 * @test Ensure that no NPE occurs while searching for reference to generic class
9750
 * 	when referenced in a unbound wildcard parameterized type
9751
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=221110"
9752
 */
9753
public void testBug221110() throws CoreException {
9754
	workingCopies = new ICompilationUnit[2];
9755
	workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
9756
		"public class X<T> {\n" + 
9757
		"}\n"
9758
	);
9759
	workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/Y.java",
9760
		"public class Y<T extends X<?>> {\n" + 
9761
		"}\n"
9762
	);
9763
	this.resultCollector.showSelection = true;
9764
	this.resultCollector.showRule = true;
9765
	IType type = this.workingCopies[0].getType("X");
9766
	search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9767
	assertSearchResults(
9768
		"src/Y.java Y [public class Y<T extends §|X|§<?>> {] ERASURE_MATCH"
9769
	);
9770
}
9771
public void testBug221110b() throws CoreException {
9772
	workingCopies = new ICompilationUnit[3];
9773
	workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/I.java",
9774
		"public interface I<T> {\n" + 
9775
		"}\n"
9776
	);
9777
	workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/X.java",
9778
		"public class X<T> {\n" + 
9779
		"}\n"
9780
	);
9781
	workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/Z.java",
9782
		"public class Z<T extends X<?> & I<?>> {\n" + 
9783
		"}\n"
9784
	);
9785
	this.resultCollector.showSelection = true;
9786
	this.resultCollector.showRule = true;
9787
	IType type = this.workingCopies[0].getType("I");
9788
	search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9789
	assertSearchResults(
9790
		"src/Z.java Z [public class Z<T extends X<?> & §|I|§<?>> {] ERASURE_MATCH"
9791
	);
9792
}
9746
}
9793
}

Return to bug 221110