mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
method references: super methods treatment in exact check
This commit is contained in:
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.impl.source.resolve.JavaResolveUtil;
|
||||
import com.intellij.psi.impl.source.resolve.ResolveCache;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.FunctionalInterfaceParameterizationUtil;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
|
||||
@@ -43,6 +44,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase implements PsiMethodReferenceExpression {
|
||||
@@ -136,8 +140,14 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
|
||||
if (containingClass != null) {
|
||||
PsiMethod[] methods = null;
|
||||
if (element instanceof PsiIdentifier) {
|
||||
final PsiExpression qualifierExpression = getQualifierExpression();
|
||||
methods = containingClass.findMethodsByName(element.getText(), qualifierExpression instanceof PsiThisExpression || qualifierExpression instanceof PsiSuperExpression);
|
||||
final String identifierName = element.getText();
|
||||
final List<PsiMethod> result = new ArrayList<PsiMethod>();
|
||||
for (HierarchicalMethodSignature signature : containingClass.getVisibleSignatures()) {
|
||||
if (identifierName.equals(signature.getName())) {
|
||||
result.add(signature.getMethod());
|
||||
}
|
||||
}
|
||||
methods = result.toArray(new PsiMethod[result.size()]);
|
||||
}
|
||||
else if (isConstructor()) {
|
||||
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(getProject());
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class Scratch
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
final List<ConcreteId> list = new ArrayList<>();
|
||||
|
||||
final List<Long> longs = list.stream()
|
||||
.map(ConcreteId::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
final List<Long> longs2 = list.stream()
|
||||
.map(AbstractId::getId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static abstract class AbstractId
|
||||
{
|
||||
private final long id;
|
||||
|
||||
public AbstractId(long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteId extends AbstractId
|
||||
{
|
||||
public ConcreteId(long id)
|
||||
{
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,6 +249,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA124613() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCollectingApplicabilityConstraints() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user