mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
method refs: fix variable initializing order (IDEA-132445)
This commit is contained in:
+3
-3
@@ -169,13 +169,13 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
|
||||
}
|
||||
LOG.assertTrue(referencedMethodReturnType != null, method);
|
||||
|
||||
session.initBounds(myExpression, method.getTypeParameters());
|
||||
|
||||
if (!PsiTreeUtil.isContextAncestor(containingClass, myExpression, false) ||
|
||||
if (!PsiTreeUtil.isContextAncestor(containingClass, myExpression, false) ||
|
||||
PsiUtil.getEnclosingStaticElement(myExpression, containingClass) != null) {
|
||||
session.initBounds(myExpression, containingClass.getTypeParameters());
|
||||
}
|
||||
|
||||
session.initBounds(myExpression, method.getTypeParameters());
|
||||
|
||||
//if i) the method reference elides NonWildTypeArguments,
|
||||
// ii) the compile-time declaration is a generic method, and
|
||||
// iii) the return type of the compile-time declaration mentions at least one of the method's type parameters;
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import java.util.function.Function;
|
||||
|
||||
interface Repository<T> {
|
||||
<S extends T> S save(S s);
|
||||
}
|
||||
|
||||
interface Builder<T> {
|
||||
|
||||
T build();
|
||||
|
||||
default <D> Builder<D> map(Function<T, D> fx) {
|
||||
return () -> fx.apply(this.build());
|
||||
}
|
||||
}
|
||||
|
||||
class Usage {
|
||||
void test(Repository<String> repository, Builder<String> sample) {
|
||||
sample.map(repository::save).build();
|
||||
sample.map((s) -> repository.save(s)).build();
|
||||
}
|
||||
}
|
||||
+4
@@ -318,6 +318,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTypeParametersInitOrder() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user