mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
method refs: reject constructor refs with 'receiver' syntax (IDEA-126484)
This commit is contained in:
@@ -33,6 +33,7 @@ public class PsiMethodReferenceUtil {
|
||||
|
||||
public static boolean hasReceiver(PsiType[] parameterTypes, QualifierResolveResult qualifierResolveResult, PsiMethodReferenceExpression methodRef) {
|
||||
if (parameterTypes.length > 0 &&
|
||||
!methodRef.isConstructor() &&
|
||||
isReceiverType(parameterTypes[0], qualifierResolveResult.getContainingClass(), qualifierResolveResult.getSubstitutor()) &&
|
||||
isStaticallyReferenced(methodRef)) {
|
||||
return true;
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import java.util.function.*;
|
||||
|
||||
class ConstructorReferences {
|
||||
public ConstructorReferences() {}
|
||||
public ConstructorReferences(String s) {}
|
||||
public ConstructorReferences(String s1, String s2) {}
|
||||
public ConstructorReferences(ConstructorReferences other) {}
|
||||
public ConstructorReferences(ConstructorReferences other1, ConstructorReferences other2) {}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Supplier<ConstructorReferences> supplier = ConstructorReferences::new;
|
||||
Function<String,ConstructorReferences> function = ConstructorReferences::new;
|
||||
BiFunction<String,String,ConstructorReferences> bifunction = ConstructorReferences::new;
|
||||
UnaryOperator<ConstructorReferences> unaryOperator = ConstructorReferences:: new;
|
||||
Function<ConstructorReferences,ConstructorReferences> unaryOperatorBaseClass = ConstructorReferences::new;
|
||||
BinaryOperator<ConstructorReferences> binaryOperator = ConstructorReferences::new;
|
||||
BiFunction<ConstructorReferences, ConstructorReferences, ConstructorReferences> binaryOperatorBaseClass = ConstructorReferences::new;
|
||||
Consumer<ConstructorReferences> consumer = ConstructorReferences::new;
|
||||
BiConsumer<ConstructorReferences,ConstructorReferences> biconsumer = ConstructorReferences::new;
|
||||
}
|
||||
}
|
||||
+4
@@ -261,6 +261,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testRejectReceiverTypesForConstructorRefs() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user