[java] compare copied enum constructors as isEquivalent (IDEA-281446)

GitOrigin-RevId: 2b2456ad69da44c92376b42ffbfb8993f2aff3c2
This commit is contained in:
Anna Kozlova
2021-11-03 13:38:18 +01:00
committed by intellij-monorepo-bot
parent 3d3d27dec4
commit eacd3576f5
3 changed files with 19 additions and 1 deletions

View File

@@ -914,7 +914,7 @@ public final class LambdaUtil {
PsiExpression function = replacer.apply(lambdaCopy);
if (function == null) return false;
JavaResolveResult resultCopy = copyCall.resolveMethodGenerics();
if (resultCopy.getElement() != oldTarget) return false;
if (!oldTarget.getManager().areElementsEquivalent(resultCopy.getElement(), oldTarget)) return false;
String copyMessage = resultCopy instanceof MethodCandidateInfo ? ((MethodCandidateInfo)resultCopy).getInferenceErrorMessage() : null;
if (!Objects.equals(origErrorMessage, copyMessage)) return false;
if (function instanceof PsiFunctionalExpression) {

View File

@@ -0,0 +1,8 @@
// "Replace lambda with method reference" "true"
import java.util.function.Consumer;
enum E {
E(System.out::println);
E(Runnable r) { }
}

View File

@@ -0,0 +1,10 @@
// "Replace lambda with method reference" "true"
import java.util.function.Consumer;
enum E {
E(() -> {
S<caret>ystem.out.println();
});
E(Runnable r) { }
}