Fix incorrect handling of @NotNull type parameters

^KT-36770 In progress
^KT-40114 Relates
^KT-28785 Relates
This commit is contained in:
Denis Zharkov
2020-07-07 18:27:09 +03:00
parent f1c68a9080
commit 037ff2fa52
21 changed files with 311 additions and 30 deletions
@@ -0,0 +1,28 @@
// FILE: SLRUMap.java
// !LANGUAGE: +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated
import org.jetbrains.annotations.NotNull;
import java.util.List;
public interface SLRUMap<V> {
void takeV(@NotNull V value);
<E> void takeE(@NotNull E value);
void takeVList(@NotNull List<@NotNull V> value);
<E> void takeEList(@NotNull List<@NotNull E> value);
}
// FILE: main.kt
fun <V> SLRUMap<V>.getOrPut(value: V, l: List<V>) {
<!INAPPLICABLE_CANDIDATE!>takeV<!>(value)
takeVList(l)
takeE(value)
takeEList(l)
if (value != null) {
takeV(value)
takeE(value)
}
}
@@ -0,0 +1,28 @@
// FILE: SLRUMap.java
// !LANGUAGE: +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated
import org.jetbrains.annotations.NotNull;
import java.util.List;
public interface SLRUMap<V> {
void takeV(@NotNull V value);
<E> void takeE(@NotNull E value);
void takeVList(@NotNull List<@NotNull V> value);
<E> void takeEList(@NotNull List<@NotNull E> value);
}
// FILE: main.kt
fun <V> SLRUMap<V>.getOrPut(value: V, l: List<V>) {
takeV(<!TYPE_MISMATCH!>value<!>)
takeVList(<!TYPE_MISMATCH!>l<!>)
takeE(<!TYPE_MISMATCH!>value<!>)
takeEList(<!TYPE_MISMATCH!>l<!>)
if (value != null) {
takeV(<!DEBUG_INFO_SMARTCAST!>value<!>)
takeE(<!DEBUG_INFO_SMARTCAST!>value<!>)
}
}
@@ -0,0 +1,13 @@
package
public fun </*0*/ V> SLRUMap<V>.getOrPut(/*0*/ value: V, /*1*/ l: kotlin.collections.List<V>): kotlin.Unit
public interface SLRUMap</*0*/ V : kotlin.Any!> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public abstract fun </*0*/ E : kotlin.Any!> takeE(/*0*/ @org.jetbrains.annotations.NotNull value: E!!): kotlin.Unit
public abstract fun </*0*/ E : kotlin.Any!> takeEList(/*0*/ @org.jetbrains.annotations.NotNull value: kotlin.collections.(Mutable)List<@org.jetbrains.annotations.NotNull E!!>): kotlin.Unit
public abstract fun takeV(/*0*/ @org.jetbrains.annotations.NotNull value: V!!): kotlin.Unit
public abstract fun takeVList(/*0*/ @org.jetbrains.annotations.NotNull value: kotlin.collections.(Mutable)List<@org.jetbrains.annotations.NotNull V!!>): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,28 @@
// FILE: SLRUMap.java
// !LANGUAGE: -ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated
import org.jetbrains.annotations.NotNull;
import java.util.List;
public interface SLRUMap<V> {
void takeV(@NotNull V value);
<E> void takeE(@NotNull E value);
void takeVList(@NotNull List<@NotNull V> value);
<E> void takeEList(@NotNull List<@NotNull E> value);
}
// FILE: main.kt
fun <V> SLRUMap<V>.getOrPut(value: V, l: List<V>) {
<!INAPPLICABLE_CANDIDATE!>takeV<!>(value)
takeVList(l)
takeE(value)
takeEList(l)
if (value != null) {
takeV(value)
takeE(value)
}
}
@@ -0,0 +1,28 @@
// FILE: SLRUMap.java
// !LANGUAGE: -ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated
import org.jetbrains.annotations.NotNull;
import java.util.List;
public interface SLRUMap<V> {
void takeV(@NotNull V value);
<E> void takeE(@NotNull E value);
void takeVList(@NotNull List<@NotNull V> value);
<E> void takeEList(@NotNull List<@NotNull E> value);
}
// FILE: main.kt
fun <V> SLRUMap<V>.getOrPut(value: V, l: List<V>) {
takeV(<!NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER!>value<!>)
takeVList(<!NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER!>l<!>)
takeE(<!NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER!>value<!>)
takeEList(<!NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER!>l<!>)
if (value != null) {
takeV(value)
takeE(value)
}
}
@@ -0,0 +1,13 @@
package
public fun </*0*/ V> SLRUMap<V>.getOrPut(/*0*/ value: V, /*1*/ l: kotlin.collections.List<V>): kotlin.Unit
public interface SLRUMap</*0*/ V : kotlin.Any!> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public abstract fun </*0*/ E : kotlin.Any!> takeE(/*0*/ @org.jetbrains.annotations.NotNull value: E): kotlin.Unit
public abstract fun </*0*/ E : kotlin.Any!> takeEList(/*0*/ @org.jetbrains.annotations.NotNull value: kotlin.collections.(Mutable)List<@org.jetbrains.annotations.NotNull E>): kotlin.Unit
public abstract fun takeV(/*0*/ @org.jetbrains.annotations.NotNull value: V): kotlin.Unit
public abstract fun takeVList(/*0*/ @org.jetbrains.annotations.NotNull value: kotlin.collections.(Mutable)List<@org.jetbrains.annotations.NotNull V>): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -22,5 +22,5 @@ interface TypePredicate : (KotlinType) -> Boolean {
fun <T : Any?> TypePredicate.expectedTypeFor(keys: Iterable<T>): Map<T, TypePredicate> =
keys.fold(SmartFMap.emptyMap<T, TypePredicate>()) { map, key ->
map.plus(key, this)
map.plus(<!NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER!>key<!>, this)
}