new inference: don't treat void as primitive type to boxing

This commit is contained in:
Anna Kozlova
2015-11-25 12:25:02 +01:00
parent e70e0ee9d0
commit 169b42916e
3 changed files with 20 additions and 2 deletions
@@ -45,14 +45,14 @@ public class TypeCompatibilityConstraint implements ConstraintFormula {
}
return assignable;
}
if (myS instanceof PsiPrimitiveType) {
if (myS instanceof PsiPrimitiveType && !PsiType.VOID.equals(myS)) {
final PsiClassType boxedType = ((PsiPrimitiveType)myS).getBoxedType(session.getManager(), session.getScope());
if (boxedType != null) {
constraints.add(new TypeCompatibilityConstraint(myT, boxedType));
return true;
}
}
if (myT instanceof PsiPrimitiveType) {
if (myT instanceof PsiPrimitiveType && !PsiType.VOID.equals(myT)) {
final PsiClassType boxedType = ((PsiPrimitiveType)myT).getBoxedType(session.getManager(), session.getScope());
if (boxedType != null) {
constraints.add(new TypeEqualityConstraint(boxedType, myS));
@@ -0,0 +1,14 @@
import java.util.function.Supplier;
class ABC {
private <T> void <warning descr="Private method 'foo(java.util.function.Supplier<T>)' is never used">foo</warning>(Supplier<T> <warning descr="Parameter 'dictSeqs' is never used">dictSeqs</warning>) {
}
private void foo(Runnable <warning descr="Parameter 'r' is never used">r</warning>) {}
{
foo(() -> bar());
foo(this::bar);
}
void bar(){}
}
@@ -171,6 +171,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testFunctionalInterfaceIncompatibilityBasedOnAbsenceOfVoidToTypeConvertion() throws Exception {
doTest();
}
private void doTest() {
doTest(true);
}