Another TypeUtils.isNullableType() introduced

This commit is contained in:
Andrey Breslav
2014-08-27 17:46:35 +04:00
parent 12d18533e8
commit d1214d2368
3 changed files with 32 additions and 1 deletions
@@ -143,7 +143,7 @@ public class CompileTimeConstantChecker {
}
private boolean checkNullValue(@NotNull JetType expectedType, @NotNull JetConstantExpression expression) {
if (!noExpectedTypeOrError(expectedType) && !expectedType.isNullable()) {
if (!noExpectedTypeOrError(expectedType) && !TypeUtils.isNullableType(expectedType)) {
return reportError(NULL_FOR_NONNULL_TYPE.on(expression, expectedType));
}
return false;
@@ -0,0 +1,26 @@
// FILE: p/SAM.java
package p;
public interface SAM<R> {
R foo();
}
// FILE: p/Util.java
package p;
public class Util {
public static void sam(SAM<Void> sam) {}
}
// FILE: k.kt
import p.*
fun test() {
Util.sam {
null
}
}
@@ -7848,6 +7848,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("sam.kt")
public void testSam() throws Exception {
doTest("compiler/testData/diagnostics/tests/platformTypes/methodCall/sam.kt");
}
@TestMetadata("singleton.kt")
public void testSingleton() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt");