mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: non wildcard parametrization: reject primitive bounds
This commit is contained in:
+1
-1
@@ -101,7 +101,7 @@ public class FunctionalInterfaceParameterizationUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
final PsiSubstitutor substitutor = session.resolveDependencies(session.getInferenceVariables());
|
||||
final PsiSubstitutor substitutor = session.retrieveNonPrimitiveEqualsBounds(session.getInferenceVariables());
|
||||
final PsiType[] newTypeParameters = new PsiType[parameters.length];
|
||||
for (int i = 0; i < typeParameters.length; i++) {
|
||||
PsiTypeParameter typeParameter = typeParameters[i];
|
||||
|
||||
+2
-2
@@ -299,11 +299,11 @@ public class InferenceSession {
|
||||
return prepareSubstitution();
|
||||
}
|
||||
|
||||
public PsiSubstitutor resolveDependencies(Collection<InferenceVariable> variables) {
|
||||
public PsiSubstitutor retrieveNonPrimitiveEqualsBounds(Collection<InferenceVariable> variables) {
|
||||
PsiSubstitutor substitutor = mySiteSubstitutor;
|
||||
for (InferenceVariable variable : variables) {
|
||||
final PsiType equalsBound = getEqualsBound(variable, substitutor);
|
||||
if (equalsBound != PsiType.NULL) {
|
||||
if (!(equalsBound instanceof PsiPrimitiveType)) {
|
||||
substitutor = substitutor.put(variable.getParameter(), equalsBound);
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
class IDEA100385 {
|
||||
void foo(N<Double> n){
|
||||
n.forEach((<error descr="Incompatible parameter types in lambda expression">double e</error>) -> { });
|
||||
}
|
||||
static interface N<E> {
|
||||
void forEach(Consumer<? extends E> consumer);
|
||||
}
|
||||
|
||||
interface Consumer<T> {
|
||||
public void accept(T t);
|
||||
}
|
||||
|
||||
}
|
||||
+4
@@ -32,6 +32,10 @@ public class FunctionalTypeWildcardParameterizationTest extends LightDaemonAnaly
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPrimitiveParameterTypes() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
|
||||
doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
|
||||
Reference in New Issue
Block a user