mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 21:41:24 +07:00
erasure return type when unchecked conversion was required deep inside (IDEA-168316)
This commit is contained in:
@@ -27,7 +27,6 @@ import com.intellij.psi.infos.MethodCandidateInfo;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -83,7 +82,6 @@ public class PsiDiamondTypeUtil {
|
||||
return areTypeArgumentsRedundant(typeArguments, expression, true, method, typeParameters);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import com.intellij.psi.util.*;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.Producer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -1924,7 +1923,22 @@ public class InferenceSession {
|
||||
|
||||
public static boolean wasUncheckedConversionPerformed(PsiElement call) {
|
||||
final Boolean erased = call.getUserData(ERASED);
|
||||
return erased != null && erased.booleanValue();
|
||||
if (erased != null && erased.booleanValue()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (call instanceof PsiCallExpression) {
|
||||
PsiExpressionList args = ((PsiCallExpression)call).getArgumentList();
|
||||
if (args != null) {
|
||||
for (PsiExpression expression : args.getExpressions()) {
|
||||
if (expression instanceof PsiNewExpression && !PsiDiamondType.hasDiamond((PsiNewExpression)expression)) {
|
||||
continue;
|
||||
}
|
||||
if (wasUncheckedConversionPerformed(expression)) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public PsiElement getContext() {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
class Foo<Z> {
|
||||
void foo(final Bar baz) {
|
||||
Z z = z(new Bar<String>(baz));
|
||||
<error descr="Incompatible types. Found: 'java.lang.Object', required: 'Z'">Z z1 = z(new Bar<>(baz));</error>
|
||||
<error descr="Incompatible types. Found: 'java.lang.Object', required: 'Z'">Z z2 = z(c(baz));</error>
|
||||
<error descr="Incompatible types. Found: 'java.lang.Object', required: 'Z'">Z z3 = z(this.<String>c(baz));</error>
|
||||
}
|
||||
|
||||
<P> Bar<P> c(Bar<P> b) {
|
||||
return b;
|
||||
}
|
||||
|
||||
private <X> Z z(Bar<X> b) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class Bar<T> {
|
||||
public Bar(Bar<T> v) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// "Replace with <>" "false"
|
||||
class Foo<Z> {
|
||||
void foo(final Bar baz) {
|
||||
Z z = z(new Bar<St<caret>ring>(baz));
|
||||
}
|
||||
|
||||
<P> Bar<P> c(Bar<P> b) {
|
||||
return b;
|
||||
}
|
||||
|
||||
private <X> Z z(Bar<X> b) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class Bar<T> {
|
||||
public Bar(Bar<T> v) {
|
||||
}
|
||||
}
|
||||
@@ -77,6 +77,10 @@ public class Diamond8HighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testRawArgumentInsideNewExpression() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user