mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
diamonds: don't accept inferred types when error appeared during inference (IDEA-154619)
This commit is contained in:
@@ -162,7 +162,12 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
|
||||
})
|
||||
: getStaticFactoryCandidateInfo(newExpression, context);
|
||||
staticFactoryRef.set(staticFactoryCandidateInfo);
|
||||
return staticFactoryCandidateInfo != null ? staticFactoryCandidateInfo.getSubstitutor() : null;
|
||||
if (staticFactoryCandidateInfo != null) {
|
||||
PsiSubstitutor substitutor = staticFactoryCandidateInfo.getSubstitutor();
|
||||
return staticFactoryCandidateInfo instanceof MethodCandidateInfo && ((MethodCandidateInfo)staticFactoryCandidateInfo).getInferenceErrorMessage() != null
|
||||
? null : substitutor;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
if (inferredSubstitutor == null) {
|
||||
|
||||
+3
-3
@@ -1,14 +1,14 @@
|
||||
class Test {
|
||||
{
|
||||
Holder h = null;
|
||||
Result<String> r1 = new Result<><error descr="'Result(D)' in 'Result' cannot be applied to '(Holder)'">(h)</error>;
|
||||
Result<String> r1 = new Result<<error descr="Cannot infer arguments"></error>>(h);
|
||||
Result<String> r2 = Result.create<error descr="'create(K)' in 'Result' cannot be applied to '(Holder)'">(h)</error>;
|
||||
|
||||
Holder dataHolder = null;
|
||||
Result<String> r3 = new Result<><error descr="'Result(D)' in 'Result' cannot be applied to '(Holder<E>)'">(new Holder<>(dataHolder))</error>;
|
||||
Result<String> r3 = new Result<<error descr="Cannot infer arguments"></error>>(new Holder<>(dataHolder));
|
||||
Result<String> r4 = Result.create<error descr="'create(K)' in 'Result' cannot be applied to '(Holder<E>)'">(new Holder<>(dataHolder))</error>;
|
||||
|
||||
Result<String> r5 = new Result<>(Holder.create<error descr="'create(Holder<M>)' in 'Holder' cannot be applied to '(Holder)'">(dataHolder)</error>);
|
||||
Result<String> r5 = new Result<<error descr="Cannot infer arguments"></error>>(Holder.create(dataHolder));
|
||||
Result<String> r6 = Result.create<error descr="'create(K)' in 'Result' cannot be applied to '(Holder)'">(Holder.create(dataHolder))</error>;
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public class ConcurrentCollectors {
|
||||
static <T, K, D, M1 extends Map<K, D>> C<T, M1> groupingBy(F<M1> f,
|
||||
C<T, D> c,
|
||||
BiConsumer<M1, T> consumer) {
|
||||
return new CImpl<>(f, consumer, arg<error descr="'arg(ConcurrentCollectors.BiOp<V>)' in 'ConcurrentCollectors.Test3' cannot be applied to '(ConcurrentCollectors.BiOp<D>)'">(c.getOp())</error>);
|
||||
return new CImpl<<error descr="Cannot infer arguments"></error>>(f, consumer, arg(c.getOp()));
|
||||
}
|
||||
|
||||
static <K, V, M2 extends ConcurrentMap<K, V>> BiOp<M2> arg(BiOp<V> op) {
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Change 1st parameter of method 'foo' from 'ArrayList<String>' to 'HashSet<E>'" "false"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
class InspecitonIssue {
|
||||
|
||||
void foo(ArrayList<String> lst) {}
|
||||
|
||||
void bar() {
|
||||
foo(new Hash<caret>Set<>());
|
||||
}
|
||||
}
|
||||
+7
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
|
||||
public class ChangeMethodSignatureFromUsage8Test extends LightQuickFixParameterizedTestCase {
|
||||
|
||||
@@ -30,4 +32,9 @@ public class ChangeMethodSignatureFromUsage8Test extends LightQuickFixParameteri
|
||||
protected LanguageLevel getLanguageLevel() {
|
||||
return LanguageLevel.JDK_1_8;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return IdeaTestUtil.getMockJdk18();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user