IDEA-122616

This commit is contained in:
Anna Kozlova
2014-03-21 14:44:09 +01:00
parent 0a516f5166
commit 60acb4b9b2
5 changed files with 32 additions and 10 deletions

View File

@@ -319,6 +319,13 @@ public class LambdaUtil {
return properties.getSubstitutor().substitute(getNormalizedType(parameters[finalLambdaIdx]));
}
}
final Map<PsiElement, PsiType> map = ourFunctionTypes.get();
if (map != null) {
final PsiType type = map.get(expression);
if (type != null) {
return type;
}
}
final JavaResolveResult resolveResult = contextCall.resolveMethodGenerics();
final PsiElement resolve = resolveResult.getElement();
if (resolve instanceof PsiMethod) {
@@ -326,13 +333,6 @@ public class LambdaUtil {
final int finalLambdaIdx = adjustLambdaIdx(lambdaIdx, (PsiMethod)resolve, parameters);
if (finalLambdaIdx < parameters.length) {
if (!tryToSubstitute) return getNormalizedType(parameters[finalLambdaIdx]);
final Map<PsiElement, PsiType> map = ourFunctionTypes.get();
if (map != null) {
final PsiType type = map.get(expression);
if (type != null) {
return type;
}
}
return PsiResolveHelper.ourGraphGuard.doPreventingRecursion(expression, true, new Computable<PsiType>() {
@Override
public PsiType compute() {

View File

@@ -1,8 +1,8 @@
class IntStream {
private void foo(IntStream s) {
s.map(i -> <error descr="Operator '<<' cannot be applied to 'int', '<lambda parameter>'">1 << i</error>);
s.map<error descr="Ambiguous method call: both 'IntStream.map(IntUnaryOperator)' and 'IntStream.map(ObjIntFunction<Integer>)' match">(i -> 1 << i)</error>;
s.map<error descr="Ambiguous method call: both 'IntStream.map(IntUnaryOperator)' and 'IntStream.map(ObjIntFunction<Integer>)' match">(i -> 1)</error>;
s.map<error descr="Ambiguous method call: both 'IntStream.map(IntUnaryOperator)' and 'IntStream.map(ObjIntFunction<T>)' match">(i -> i)</error>;
s.map<error descr="Ambiguous method call: both 'IntStream.map(IntUnaryOperator)' and 'IntStream.map(ObjIntFunction<Integer>)' match">(i -> i)</error>;
}
public static void main(String[] args) {

View File

@@ -25,7 +25,7 @@ class ReturnTypeIncompatibility {
}
public static void main(String[] args) {
call<error descr="Ambiguous method call: both 'ReturnTypeIncompatibility.call(I1<P>)' and 'ReturnTypeIncompatibility.call(I2<P>)' match">(i-> {return i;})</error>;
call<error descr="Ambiguous method call: both 'ReturnTypeIncompatibility.call(I1<Integer>)' and 'ReturnTypeIncompatibility.call(I2<P>)' match">(i-> {return i;})</error>;
}
}

View File

@@ -0,0 +1,18 @@
import java.util.function.Function;
class ChoiceBox<T> {
static {
ChoiceBox<Item> confParamField1 = new ChoiceBox<>("", p -> p.getName());
ChoiceBox<Item> confParamField2 = new ChoiceBox<Item>("", p -> p.getName());
}
public ChoiceBox(T... options) {}
public ChoiceBox(String caption, Function<T, String> itemCaption) {}
public static class Item {
public String getName() {
return null;
}
}
}

View File

@@ -170,6 +170,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testIDEA122616() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
}