Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/notNullAnnotation.kt
T
Denis Zharkov 037ff2fa52 Fix incorrect handling of @NotNull type parameters
^KT-36770 In progress
^KT-40114 Relates
^KT-28785 Relates
2020-07-22 10:16:14 +03:00

27 lines
718 B
Kotlin
Vendored

// !LANGUAGE: +NewInference
// FILE: SmartFMap.java
public class SmartFMap<K, V> implements java.util.Map<K, V> {
public static < K, V> SmartFMap<K, V> emptyMap() {
return null;
}
public SmartFMap < K, V> plus(@org.jetbrains.annotations.NotNull K key, V value) {
return null;
}
}
// FILE: main.kt
class KotlinType
interface TypePredicate : (KotlinType) -> Boolean {
override fun invoke(typeToCheck: KotlinType): Boolean
}
fun <T : Any?> TypePredicate.expectedTypeFor(keys: Iterable<T>): Map<T, TypePredicate> =
keys.fold(SmartFMap.emptyMap<T, TypePredicate>()) { map, key ->
map.plus(<!NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER!>key<!>, this)
}