lambda: do not override already inferred types from parent (IDEA-92733)

This commit is contained in:
Anna Kozlova
2012-10-12 17:31:16 +02:00
parent 59d8eafbce
commit 289ee1d04c
3 changed files with 28 additions and 2 deletions
@@ -993,7 +993,10 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
if (method == null || methodParamsDependOn(typeParameter, expression,
functionalInterfaceType, method.getParameterList().getParameters(),
LambdaUtil.getSubstitutor(method, resolveResult))) {
return getFailedInferenceConstraint(typeParameter);
if (expression instanceof PsiMethodReferenceExpression) {
return getFailedInferenceConstraint(typeParameter);
}
return null;
}
}
}
@@ -0,0 +1,19 @@
class LambdaTest {
public void highlightsTheBug(Stream<String> stream) {
stream.flatMap((Block<? super String> sink, String element) -> {});
}
public interface Block<B> {
void apply(B t);
}
public interface Stream<S> {
<R> Stream<R> flatMap(FlatMapper<? super S, R> mapper);
}
public interface FlatMapper<F, R> {
void flatMapInto(Block<? super R> sink, F element);
}
}
@@ -152,7 +152,11 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testRecursiveAccess() throws Exception {
doTest();
}
public void testIncompatibleFormalParameterTypes() throws Exception {
doTest();
}
private void doTest() throws Exception {
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
}