new inference: non wildcard parametrization: reject primitive bounds

This commit is contained in:
Anna Kozlova
2014-03-03 13:43:47 +01:00
parent ab2348a911
commit eb3695fffc
4 changed files with 20 additions and 3 deletions
@@ -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];
@@ -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);
}
}
@@ -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);
}
}
@@ -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);