Do not wrap flexible types into Nullable/NotNull types
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
// FILE: p/PsiElement.java
|
||||||
|
|
||||||
|
package p;
|
||||||
|
|
||||||
|
public interface PsiElement {}
|
||||||
|
|
||||||
|
// FILE: p/JetExpression.java
|
||||||
|
|
||||||
|
package p;
|
||||||
|
|
||||||
|
public interface JetExpression extends PsiElement {}
|
||||||
|
|
||||||
|
// FILE: p/Util.java
|
||||||
|
|
||||||
|
package p;
|
||||||
|
|
||||||
|
public class Util {
|
||||||
|
|
||||||
|
public static <T extends PsiElement> T getParentOfType(@Nullable PsiElement element, @NotNull Class<T> aClass) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void on(JetExpression e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: k.kt
|
||||||
|
|
||||||
|
import p.*
|
||||||
|
|
||||||
|
fun test(e: JetExpression) {
|
||||||
|
Util.on(
|
||||||
|
Util.getParentOfType(e, javaClass<JetExpression>()) ?: e
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> javaClass(): Class<T> = null!!
|
||||||
@@ -7717,6 +7717,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("getParentOfType.kt")
|
||||||
|
public void testGetParentOfType() throws Exception {
|
||||||
|
doTest("compiler/testData/diagnostics/tests/platformTypes/getParentOfType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inference.kt")
|
@TestMetadata("inference.kt")
|
||||||
public void testInference() throws Exception {
|
public void testInference() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/inference.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/inference.kt");
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ public class TypeUtils {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static JetType makeNullableAsSpecified(@NotNull JetType type, boolean nullable) {
|
public static JetType makeNullableAsSpecified(@NotNull JetType type, boolean nullable) {
|
||||||
|
if (TypesPackage.isFlexible(type)) return type;
|
||||||
|
|
||||||
// Wrapping serves two purposes here
|
// Wrapping serves two purposes here
|
||||||
// 1. It's requires less memory than copying with a changed nullability flag: a copy has many fields, while a wrapper has only one
|
// 1. It's requires less memory than copying with a changed nullability flag: a copy has many fields, while a wrapper has only one
|
||||||
// 2. It preserves laziness of types
|
// 2. It preserves laziness of types
|
||||||
|
|||||||
Reference in New Issue
Block a user