method refs: check first parameter if it could be a receiver for varargs methods (IDEA-127506)

This commit is contained in:
Anna Kozlova
2014-07-18 18:19:20 +02:00
parent eff45674ae
commit 067ef9e309
3 changed files with 30 additions and 1 deletions
@@ -970,7 +970,8 @@ public class InferenceSession {
addConstraint(new TypeCompatibilityConstraint(getParameterType(parameters, i, PsiSubstitutor.EMPTY, varargs), pType));
}
}
else if (parameters.length + 1 == functionalMethodParameters.length && !varargs || !isStatic && varargs && functionalMethodParameters.length > 0) { //instance methods
else if (parameters.length + 1 == functionalMethodParameters.length && !varargs ||
!isStatic && varargs && functionalMethodParameters.length > 0 && PsiMethodReferenceUtil.hasReceiver(reference, method)) { //instance methods
initBounds(containingClass.getTypeParameters());
final PsiType pType = signature.getParameterTypes()[0];
@@ -0,0 +1,24 @@
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
class Validator {
static boolean thereAreConstraintViolationsIn1(final Stream<Object> objectStream, Validator validator) {
Stream<Set<List<Object>>> rStream = objectStream
.map(validator::validate);
return rStream
.flatMap(set -> set.stream())
.findAny()
.isPresent();
}
static void thereAreConstraintViolationsIn(final Stream<Object> objectStream, Validator validator) {
Stream<Set<List<Object>>> rStream = objectStream.map(validator ::validate);
Stream<Set<List<Object>>> lStream = objectStream.map((a) -> validator.validate(a));
}
<T> Set<List<T>> validate(T var1, Class<?> ... var2) {
return null;
}
}
@@ -277,6 +277,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testIDEA127506() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
}