mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: ignore trivial dependencies
This commit is contained in:
+12
-9
@@ -17,6 +17,7 @@ package com.intellij.psi.impl.source.resolve.graphInference;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.light.LightTypeParameter;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -49,6 +50,10 @@ public class InferenceVariable extends LightTypeParameter {
|
||||
}
|
||||
|
||||
public boolean addBound(PsiType classType, InferenceBound inferenceBound) {
|
||||
if (inferenceBound == InferenceBound.EQ &&
|
||||
PsiUtil.resolveClassInClassTypeOnly(classType) == this) {
|
||||
return false;
|
||||
}
|
||||
List<PsiType> list = myBounds.get(inferenceBound);
|
||||
if (list == null) {
|
||||
list = new ArrayList<PsiType>();
|
||||
@@ -77,20 +82,18 @@ public class InferenceVariable extends LightTypeParameter {
|
||||
}
|
||||
}
|
||||
|
||||
if (!session.hasCapture(this) && dependencies.isEmpty()) {
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
next:
|
||||
for (InferenceVariable variable : session.getInferenceVariables()) {
|
||||
if (!dependencies.contains(variable) && variable != this) {
|
||||
nextBound:
|
||||
for (List<PsiType> bounds : myBounds.values()) { //todo
|
||||
for (List<PsiType> bounds : variable.myBounds.values()) { //todo
|
||||
if (bounds != null) {
|
||||
for (PsiType bound : bounds) {
|
||||
final Set<InferenceVariable> deps = new HashSet<InferenceVariable>();
|
||||
session.collectDependencies(bound, deps);
|
||||
if (deps.isEmpty()) {
|
||||
continue nextBound;
|
||||
}
|
||||
|
||||
if (deps.contains(this)) {
|
||||
final InferenceVariable inferenceVariable = session.getInferenceVariable(bound);
|
||||
if (inferenceVariable == this) {
|
||||
dependencies.add(variable);
|
||||
continue next;
|
||||
}
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
class ExplicitLambdaNoParams {
|
||||
interface I<T> {
|
||||
T a();
|
||||
}
|
||||
|
||||
<F> I<F> foo(I<F> iff) { return null;}
|
||||
|
||||
{
|
||||
foo(() -> foo(() -> 1)).a();
|
||||
I<Integer> a1 = foo(() -> foo(() -> 1)).a();
|
||||
}
|
||||
}
|
||||
|
||||
class LambdaWithFormalParameterTypes {
|
||||
|
||||
interface I<T> {
|
||||
T a(int p);
|
||||
}
|
||||
|
||||
<F> I<F> foo(I<F> iff) { return null;}
|
||||
|
||||
{
|
||||
foo((int a) -> foo((int b) -> 1)).a(0);
|
||||
I<Integer> a1 = foo((int a) -> foo((int b) -> 1)).a(0);
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -94,6 +94,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA126109() { doTest(); }
|
||||
public void testIDEA126809() { doTest(); }
|
||||
public void testIDEA124424() { doTest(); }
|
||||
public void testNestedLambdaExpressions1() { doTest(); }
|
||||
|
||||
public void testIDEA127596() throws Exception {
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user