mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
preserve captured wildcards during non wildcard parameterization (IDEA-132690)
This commit is contained in:
@@ -477,6 +477,12 @@ public class GenericsUtil {
|
||||
}
|
||||
|
||||
public static PsiType eliminateWildcards(PsiType type, final boolean eliminateInTypeArguments) {
|
||||
return eliminateWildcards(type, eliminateInTypeArguments, !eliminateInTypeArguments);
|
||||
}
|
||||
|
||||
public static PsiType eliminateWildcards(PsiType type,
|
||||
final boolean eliminateInTypeArguments,
|
||||
boolean eliminateCapturedWildcards) {
|
||||
if (eliminateInTypeArguments && type instanceof PsiClassType) {
|
||||
PsiClassType classType = (PsiClassType)type;
|
||||
JavaResolveResult resolveResult = classType.resolveGenerics();
|
||||
@@ -508,7 +514,8 @@ public class GenericsUtil {
|
||||
else if (type instanceof PsiWildcardType) {
|
||||
final PsiType bound = ((PsiWildcardType)type).getBound();
|
||||
return eliminateWildcards(bound != null ? bound : ((PsiWildcardType)type).getExtendsBound(), false);//object
|
||||
} else if (type instanceof PsiCapturedWildcardType && !eliminateInTypeArguments) {
|
||||
}
|
||||
else if (type instanceof PsiCapturedWildcardType && eliminateCapturedWildcards) {
|
||||
return eliminateWildcards(((PsiCapturedWildcardType)type).getUpperBound(), false);
|
||||
}
|
||||
return type;
|
||||
|
||||
+1
-1
@@ -177,7 +177,7 @@ public class FunctionalInterfaceParameterizationUtil {
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
PsiType paramType = parameters[i];
|
||||
if (paramType instanceof PsiWildcardType) {
|
||||
final PsiType bound = GenericsUtil.eliminateWildcards(((PsiWildcardType)paramType).getBound(), false);
|
||||
final PsiType bound = GenericsUtil.eliminateWildcards(((PsiWildcardType)paramType).getBound(), false, false);
|
||||
if (((PsiWildcardType)paramType).isSuper()) {
|
||||
newParameters[i] = bound;
|
||||
}
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
interface Test {
|
||||
CompletableFuture<?> doWork();
|
||||
}
|
||||
|
||||
class Worker {
|
||||
Test test;
|
||||
|
||||
public void stuff() {
|
||||
|
||||
test.doWork()
|
||||
.exceptionally(t -> null);
|
||||
}
|
||||
}
|
||||
+4
@@ -212,6 +212,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPreserveCapturedWildcardsDuringNonWildcardParameterization() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user