mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
diamonds: simulate resolved constructor with generated static factory (IDEA-195813)
This commit is contained in:
@@ -1712,8 +1712,18 @@ public class HighlightMethodUtil {
|
||||
try {
|
||||
final PsiDiamondType diamondType = constructorCall instanceof PsiNewExpression ? PsiDiamondType.getDiamondType((PsiNewExpression)constructorCall) : null;
|
||||
final JavaResolveResult staticFactory = diamondType != null ? diamondType.getStaticFactory() : null;
|
||||
applicable = staticFactory instanceof MethodCandidateInfo ? ((MethodCandidateInfo)staticFactory).isApplicable()
|
||||
: result != null && result.isApplicable();
|
||||
if (staticFactory instanceof MethodCandidateInfo) {
|
||||
if (((MethodCandidateInfo)staticFactory).isApplicable()) {
|
||||
result = (MethodCandidateInfo)staticFactory;
|
||||
constructor = ((MethodCandidateInfo)staticFactory).getElement();
|
||||
}
|
||||
else {
|
||||
applicable = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
applicable = result != null && result.isApplicable();
|
||||
}
|
||||
}
|
||||
catch (IndexNotReadyException e) {
|
||||
// ignore
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class Foo {
|
||||
private final Singleton<B> singletonB = new Singleton<>(() -> f());
|
||||
static B f() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface B {
|
||||
String getData();
|
||||
}
|
||||
|
||||
class Singleton<T> {
|
||||
public Singleton(Supplier<T> supplier) { }
|
||||
public Singleton(T instance) { }
|
||||
}
|
||||
@@ -101,6 +101,10 @@ public class Diamond8HighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testOverloadedConstructorsUnresolvedWithoutDiamonds() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user