mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
treat conditional expressions with new expressions with diamonds inside as poly
EA-76546 - assert: InferenceSessionContainer.treeWalkUp
This commit is contained in:
@@ -169,9 +169,13 @@ public class PsiPolyExpressionUtil {
|
||||
}
|
||||
if (expr == null) return null;
|
||||
PsiType type = null;
|
||||
if (expr instanceof PsiNewExpression || hasStandaloneForm(expr)) {
|
||||
//A class instance creation expression (§15.9) for a class that is convertible to a numeric type.
|
||||
//As numeric classes do not have type parameters, at this point expressions with diamonds could be ignored
|
||||
if (expr instanceof PsiNewExpression && !PsiDiamondType.hasDiamond((PsiNewExpression)expr) ||
|
||||
hasStandaloneForm(expr)) {
|
||||
type = expr.getType();
|
||||
} else if (expr instanceof PsiMethodCallExpression) {
|
||||
}
|
||||
else if (expr instanceof PsiMethodCallExpression) {
|
||||
final PsiMethod method = ((PsiMethodCallExpression)expr).resolveMethod();
|
||||
if (method != null) {
|
||||
type = method.getReturnType();
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
class FImpl<K> {
|
||||
public FImpl(K k) {
|
||||
}
|
||||
|
||||
public void myMethod() {
|
||||
foo (false ? new FImpl<>(null) : null);
|
||||
}
|
||||
|
||||
private <T> T foo(final T bar) {
|
||||
return null;
|
||||
}
|
||||
private <T> T foo(final String bar) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -437,6 +437,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTreatConditionalExpressionAsPolyIfNewExpressionWithDiamondsIsUsed() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testVariableNamesOfNestedCalls() throws Exception {
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
|
||||
String filePath = BASE_PATH + "/" + getTestName(false) + ".java";
|
||||
|
||||
Reference in New Issue
Block a user