mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
resolve on nested captures (IDEA-156170)
This commit is contained in:
@@ -28,6 +28,7 @@ import com.intellij.psi.scope.JavaScopeProcessorEvent;
|
||||
import com.intellij.psi.scope.MethodProcessorSetupFailedException;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import com.intellij.psi.scope.processor.MethodsProcessor;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -127,8 +128,7 @@ public class PsiScopesUtil {
|
||||
processTypeDeclarations(lub, place, processor);
|
||||
}
|
||||
else if (type instanceof PsiCapturedWildcardType) {
|
||||
final PsiType upperBound =
|
||||
PsiClassImplUtil.correctType(((PsiCapturedWildcardType)type).getUpperBound(), place.getResolveScope());
|
||||
final PsiType upperBound = getUpperBound((PsiCapturedWildcardType)type, place);
|
||||
if (upperBound != null) {
|
||||
processTypeDeclarations(PsiUtil.captureToplevelWildcards(upperBound, place), place, processor);
|
||||
}
|
||||
@@ -142,6 +142,15 @@ public class PsiScopesUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static PsiType getUpperBound(PsiCapturedWildcardType type, PsiElement place) {
|
||||
GlobalSearchScope placeResolveScope = place.getResolveScope();
|
||||
PsiType upperBound = PsiClassImplUtil.correctType(type.getUpperBound(), placeResolveScope);
|
||||
while (upperBound instanceof PsiCapturedWildcardType) {
|
||||
upperBound = PsiClassImplUtil.correctType(((PsiCapturedWildcardType)upperBound).getUpperBound(), placeResolveScope);
|
||||
}
|
||||
return upperBound;
|
||||
}
|
||||
|
||||
public static boolean resolveAndWalk(@NotNull PsiScopeProcessor processor,
|
||||
@NotNull PsiJavaCodeReferenceElement ref,
|
||||
@Nullable PsiElement maxScope) {
|
||||
@@ -355,8 +364,7 @@ public class PsiScopesUtil {
|
||||
processQualifierType(((PsiDisjunctionType)type).getLeastUpperBound(), processor, manager, methodCall);
|
||||
}
|
||||
else if (type instanceof PsiCapturedWildcardType) {
|
||||
final PsiType upperBound =
|
||||
PsiClassImplUtil.correctType(((PsiCapturedWildcardType)type).getUpperBound(), methodCall.getResolveScope());
|
||||
final PsiType upperBound = getUpperBound((PsiCapturedWildcardType)type, methodCall);
|
||||
if (upperBound != null) {
|
||||
processQualifierType(PsiUtil.captureToplevelWildcards(upperBound, methodCall), processor, manager, methodCall);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
class Test {
|
||||
public void entitySetChanged(EntitySetEvent<? extends Number> event) {
|
||||
event.getUpdatedEntities().forEach(entity -> {
|
||||
entity.intValue();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
interface EntitySetEvent<V> {
|
||||
Collection<? extends V> getUpdatedEntities();
|
||||
}
|
||||
@@ -990,4 +990,8 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testUnifiedSubstitutorUpInTheHierarchy() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNestedCaptures() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user