[FIR] Preserve enhanced mutability when nullability was enhanced for warning

#KT-56989
This commit is contained in:
Kirill Rakhman
2023-10-23 11:57:32 +02:00
committed by Space Team
parent a63ec9efdc
commit 2005446296
10 changed files with 118 additions and 12 deletions
@@ -0,0 +1,27 @@
// NULLABILITY_ANNOTATIONS: @org.jetbrains.annotations:warn
// DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: ReadOnly.java
package org.jetbrains.annotations;
public @interface ReadOnly {}
// FILE: J.java
import java.util.List;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.ReadOnly;
public class J {
@ReadOnly
@Nullable
public static List<String> foo() {
return null;
}
}
// FILE: main.kt
fun main() {
takeMutable(<!ARGUMENT_TYPE_MISMATCH!>J.foo()<!>)
}
fun takeMutable(l: MutableList<String>) {}
@@ -0,0 +1,27 @@
// NULLABILITY_ANNOTATIONS: @org.jetbrains.annotations:warn
// DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: ReadOnly.java
package org.jetbrains.annotations;
public @interface ReadOnly {}
// FILE: J.java
import java.util.List;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.ReadOnly;
public class J {
@ReadOnly
@Nullable
public static List<String> foo() {
return null;
}
}
// FILE: main.kt
fun main() {
takeMutable(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>J.foo()<!>)
}
fun takeMutable(l: MutableList<String>) {}