mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
overload resolution: force substitutor calculation (IDEA-128174)
This commit is contained in:
@@ -180,7 +180,7 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
@NotNull
|
||||
public PsiSubstitutor getSubstitutor(boolean includeReturnConstraint) {
|
||||
PsiSubstitutor substitutor = myCalcedSubstitutor;
|
||||
if (substitutor == null || !includeReturnConstraint && myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
|
||||
if (substitutor == null || !includeReturnConstraint && myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8) || isOverloadCheck()) {
|
||||
PsiSubstitutor incompleteSubstitutor = super.getSubstitutor();
|
||||
PsiMethod method = getElement();
|
||||
if (myTypeArguments == null) {
|
||||
@@ -189,7 +189,7 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
final PsiSubstitutor inferredSubstitutor = inferTypeArguments(DefaultParameterTypeInferencePolicy.INSTANCE, includeReturnConstraint);
|
||||
|
||||
if (!stackStamp.mayCacheNow() ||
|
||||
!ourOverloadGuard.currentStack().isEmpty() ||
|
||||
isOverloadCheck() ||
|
||||
!includeReturnConstraint && myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8) ||
|
||||
getMarkerList() != null && PsiResolveHelper.ourGraphGuard.currentStack().contains(getMarkerList().getParent())) {
|
||||
return inferredSubstitutor;
|
||||
@@ -209,6 +209,10 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
return substitutor;
|
||||
}
|
||||
|
||||
public static boolean isOverloadCheck() {
|
||||
return !ourOverloadGuard.currentStack().isEmpty();
|
||||
}
|
||||
|
||||
|
||||
public boolean isTypeArgumentsApplicable() {
|
||||
return isTypeArgumentsApplicable(false);
|
||||
|
||||
@@ -86,12 +86,13 @@ public class JavaResolveCache {
|
||||
|
||||
@Nullable
|
||||
public <T extends PsiExpression> PsiType getType(@NotNull T expr, @NotNull Function<T, PsiType> f) {
|
||||
PsiType type = getCachedType(expr);
|
||||
final boolean isOverloadCheck = MethodCandidateInfo.isOverloadCheck();
|
||||
PsiType type = !isOverloadCheck ? getCachedType(expr) : null;
|
||||
if (type == null) {
|
||||
final RecursionGuard.StackStamp dStackStamp = PsiDiamondType.ourDiamondGuard.markStack();
|
||||
final RecursionGuard.StackStamp gStackStamp = PsiResolveHelper.ourGraphGuard.markStack();
|
||||
type = f.fun(expr);
|
||||
if (!dStackStamp.mayCacheNow() || !gStackStamp.mayCacheNow() || !MethodCandidateInfo.ourOverloadGuard.currentStack().isEmpty()) {
|
||||
if (!dStackStamp.mayCacheNow() || !gStackStamp.mayCacheNow() || isOverloadCheck) {
|
||||
return type;
|
||||
}
|
||||
if (type == null) type = TypeConversionUtil.NULL_TYPE;
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ public class MethodCandidatesProcessor extends MethodsProcessor{
|
||||
public PsiType[] getArgumentTypes() {
|
||||
if (myExpressionTypes == null && argumentList != null) {
|
||||
final PsiType[] expressionTypes = getExpressionTypes(argumentList);
|
||||
if (!MethodCandidateInfo.ourOverloadGuard.currentStack().isEmpty()) {
|
||||
if (MethodCandidateInfo.isOverloadCheck()) {
|
||||
return expressionTypes;
|
||||
}
|
||||
myExpressionTypes = expressionTypes;
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
class Test {
|
||||
|
||||
{
|
||||
Matcher<? super List<String>> m = not(empty());
|
||||
}
|
||||
|
||||
static <E> Matcher<Collection<E>> empty() {
|
||||
return null;
|
||||
}
|
||||
|
||||
static <T> Matcher<T> not(Matcher<T> matcher) {
|
||||
return null;
|
||||
}
|
||||
|
||||
static <T> Matcher<T> not(T value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
static class Matcher<K> {}
|
||||
}
|
||||
|
||||
+4
@@ -196,6 +196,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA128174() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user