Adjust test data for postponing ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated

^KT-55357 Related
^KT-36770 Related
This commit is contained in:
Denis.Zharkov
2021-08-11 17:43:49 +03:00
committed by Space Team
parent d34bd2e8c0
commit cd0d6d2773
72 changed files with 334 additions and 165 deletions
@@ -1,34 +1,34 @@
fun valuesNotNull(map: MutableMap<Int, String>) {
map.computeIfPresent(1) { k, v -> v.length.toString() ?: null }
// SUCCESS
// ORIGINAL: fun computeIfPresent(K, BiFunction<in K, in V & Any, out V?>): V? defined in kotlin.collections.MutableMap
// ORIGINAL: fun computeIfPresent(K, BiFunction<in K, in V, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun computeIfPresent(Int, BiFunction<in Int, in String, out String?>): String? defined in kotlin.collections.MutableMap
}
fun valuesNullable(map: MutableMap<Int, String?>) {
map.computeIfPresent(1) { k, v -> v?.length?.toString() }
// SUCCESS
// ORIGINAL: fun computeIfPresent(K, BiFunction<in K, in V & Any, out V?>): V? defined in kotlin.collections.MutableMap
// ORIGINAL: fun computeIfPresent(K, BiFunction<in K, in V, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun computeIfPresent(Int, BiFunction<in Int, in String, out String?>): String? defined in kotlin.collections.MutableMap
}
fun <T : String?> valuesT(map: MutableMap<Int, T>, newValue: T) {
map.computeIfPresent(1) { k, v -> v?.length.toString() ?: null }
// SUCCESS
// ORIGINAL: fun computeIfPresent(K, BiFunction<in K, in V & Any, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun computeIfPresent(Int, BiFunction<in Int, in T & Any, out T?>): T? defined in kotlin.collections.MutableMap
// ORIGINAL: fun computeIfPresent(K, BiFunction<in K, in V, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun computeIfPresent(Int, BiFunction<in Int, in T, out T?>): T? defined in kotlin.collections.MutableMap
}
fun <T : Any> valuesTNotNull(map: MutableMap<Int, T>, newValue: T) {
map.computeIfPresent(1) { k, v -> null }
// SUCCESS
// ORIGINAL: fun computeIfPresent(K, BiFunction<in K, in V & Any, out V?>): V? defined in kotlin.collections.MutableMap
// ORIGINAL: fun computeIfPresent(K, BiFunction<in K, in V, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun computeIfPresent(Int, BiFunction<in Int, in T, out T?>): T? defined in kotlin.collections.MutableMap
}
fun <T : Any> valuesTNullable(map: MutableMap<Int, T?>, newValue: T?) {
map.computeIfPresent(1) { k, v -> null }
// SUCCESS
// ORIGINAL: fun computeIfPresent(K, BiFunction<in K, in V & Any, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun computeIfPresent(Int, BiFunction<in Int, in T & Any, out T?>): T? defined in kotlin.collections.MutableMap
// ORIGINAL: fun computeIfPresent(K, BiFunction<in K, in V, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun computeIfPresent(Int, BiFunction<in Int, in T, out T?>): T? defined in kotlin.collections.MutableMap
}
@@ -1,42 +1,42 @@
fun valuesNotNull(map: MutableMap<Int, String>) {
map.merge(1, "x") { old, new -> old + new }
// SUCCESS
// ORIGINAL: fun merge(K, V & Any, BiFunction<in V & Any, in V & Any, out V?>): V? defined in kotlin.collections.MutableMap
// ORIGINAL: fun merge(K, V, BiFunction<in V, in V, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun merge(Int, String, BiFunction<in String, in String, out String?>): String? defined in kotlin.collections.MutableMap
}
fun valuesNullable(map: MutableMap<Int, String?>) {
map.merge(1, "x") { old, new -> old + new }
// SUCCESS
// ORIGINAL: fun merge(K, V & Any, BiFunction<in V & Any, in V & Any, out V?>): V? defined in kotlin.collections.MutableMap
// ORIGINAL: fun merge(K, V, BiFunction<in V, in V, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun merge(Int, String, BiFunction<in String, in String, out String?>): String? defined in kotlin.collections.MutableMap
map.merge(1, null) { old, new -> old + new }
// UNSAFE_CALL_ERROR
// ORIGINAL: fun merge(K, V & Any, BiFunction<in V & Any, in V & Any, out V?>): V? defined in kotlin.collections.MutableMap
// ORIGINAL: fun merge(K, V, BiFunction<in V, in V, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun merge(Int, String, BiFunction<in String, in String, out String?>): String? defined in kotlin.collections.MutableMap
}
fun <T> valuesT(map: MutableMap<Int, T>, newValue: T) {
map.merge(1, newValue) { old, new -> null }
// OTHER_ERROR
// ORIGINAL: fun merge(K, V & Any, BiFunction<in V & Any, in V & Any, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun merge(Int, T & Any, BiFunction<in T & Any, in T & Any, out T?>): T? defined in kotlin.collections.MutableMap
// SUCCESS
// ORIGINAL: fun merge(K, V, BiFunction<in V, in V, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun merge(Int, T, BiFunction<in T, in T, out T?>): T? defined in kotlin.collections.MutableMap
}
fun <T : Any> valuesTNotNull(map: MutableMap<Int, T>, newValue: T) {
map.merge(1, newValue) { old, new -> null }
// SUCCESS
// ORIGINAL: fun merge(K, V & Any, BiFunction<in V & Any, in V & Any, out V?>): V? defined in kotlin.collections.MutableMap
// ORIGINAL: fun merge(K, V, BiFunction<in V, in V, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun merge(Int, T, BiFunction<in T, in T, out T?>): T? defined in kotlin.collections.MutableMap
}
fun <T : Any> valuesTNullable(map: MutableMap<Int, T?>, newValue: T?) {
map.merge(1, newValue) { old, new -> new }
// UNSAFE_CALL_ERROR
// ORIGINAL: fun merge(K, V & Any, BiFunction<in V & Any, in V & Any, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun merge(Int, T & Any, BiFunction<in T & Any, in T & Any, out T?>): T? defined in kotlin.collections.MutableMap
// ORIGINAL: fun merge(K, V, BiFunction<in V, in V, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun merge(Int, T, BiFunction<in T, in T, out T?>): T? defined in kotlin.collections.MutableMap
map.merge(1, newValue!!) { old, new -> new }
// SUCCESS
// ORIGINAL: fun merge(K, V & Any, BiFunction<in V & Any, in V & Any, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun merge(Int, T & Any, BiFunction<in T & Any, in T & Any, out T?>): T? defined in kotlin.collections.MutableMap
// ORIGINAL: fun merge(K, V, BiFunction<in V, in V, out V?>): V? defined in kotlin.collections.MutableMap
// SUBSTITUTED: fun merge(Int, T, BiFunction<in T, in T, out T?>): T? defined in kotlin.collections.MutableMap
}
@@ -3,11 +3,11 @@ import java.util.*
fun use() {
Optional.empty<String>()
// SUCCESS
// ORIGINAL: fun <T : Any!> empty(): Optional<T & Any> defined in java.util.Optional
// ORIGINAL: fun <T : Any!> empty(): Optional<T> defined in java.util.Optional
// SUBSTITUTED: fun <T : Any!> empty(): Optional<String> defined in java.util.Optional
Optional.empty<String?>()
// SUCCESS
// ORIGINAL: fun <T : Any!> empty(): Optional<T & Any> defined in java.util.Optional
// ORIGINAL: fun <T : Any!> empty(): Optional<T> defined in java.util.Optional
// SUBSTITUTED: fun <T : Any!> empty(): Optional<String> defined in java.util.Optional
}
@@ -3,14 +3,14 @@ import java.util.*
fun use(v: Optional<String>) {
v.get()
// SUCCESS
// ORIGINAL: fun get(): T & Any defined in java.util.Optional
// ORIGINAL: fun get(): T defined in java.util.Optional
// SUBSTITUTED: fun get(): String defined in java.util.Optional
}
fun use2(v: Optional<String?>) {
v.get()
// SUCCESS
// ORIGINAL: fun get(): T & Any defined in java.util.Optional
// ORIGINAL: fun get(): T defined in java.util.Optional
// SUBSTITUTED: fun get(): String defined in java.util.Optional
}
@@ -3,14 +3,14 @@ import java.util.*
fun use(v: Optional<String>) {
v.ifPresent { value -> }
// SUCCESS
// ORIGINAL: fun ifPresent(Consumer<in T & Any>): Unit defined in java.util.Optional
// ORIGINAL: fun ifPresent(Consumer<in T>): Unit defined in java.util.Optional
// SUBSTITUTED: fun ifPresent(Consumer<in String>): Unit defined in java.util.Optional
}
fun use2(v: Optional<String?>) {
v.ifPresent { value -> }
// SUCCESS
// ORIGINAL: fun ifPresent(Consumer<in T & Any>): Unit defined in java.util.Optional
// ORIGINAL: fun ifPresent(Consumer<in T>): Unit defined in java.util.Optional
// SUBSTITUTED: fun ifPresent(Consumer<in String>): Unit defined in java.util.Optional
}
@@ -3,17 +3,17 @@ import java.util.*
fun use() {
val x: String? = "x"
Optional.of(x)
// SUCCESS
// ORIGINAL: fun <T : Any!> of(T & Any): Optional<T & Any> defined in java.util.Optional
// UNSAFE_CALL_ERROR
// ORIGINAL: fun <T : Any!> of(T): Optional<T> defined in java.util.Optional
// SUBSTITUTED: fun <T : Any!> of(String): Optional<String> defined in java.util.Optional
Optional.of(x!!)
// SUCCESS
// ORIGINAL: fun <T : Any!> of(T & Any): Optional<T & Any> defined in java.util.Optional
// ORIGINAL: fun <T : Any!> of(T): Optional<T> defined in java.util.Optional
// SUBSTITUTED: fun <T : Any!> of(String): Optional<String> defined in java.util.Optional
Optional.ofNullable(x)
// SUCCESS
// ORIGINAL: fun <T : Any!> ofNullable(T?): Optional<T & Any> defined in java.util.Optional
// ORIGINAL: fun <T : Any!> ofNullable(T?): Optional<T> defined in java.util.Optional
// SUBSTITUTED: fun <T : Any!> ofNullable(String?): Optional<String> defined in java.util.Optional
}