8b49a1d660
It's parameter is FQ-name of class (currently only from builtins) that added as supertype to annotated Java class. Parameters of annotated class used as non-flexible arguments of added supertype, that helps to propagate more precise types when using in Kotlin. Some standard JDK collections loaded as they annotated with PurelyImplements. See tests for clarification. Before: ArrayList<Int>.add(x: Int!) // possible to add null After: ArrayList<Int>.add(x: Int) // impossible to add null #KT-7628 Fixed #KT-7835 Fixed
32 lines
589 B
Kotlin
Vendored
32 lines
589 B
Kotlin
Vendored
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
|
|
|
import java.util.*
|
|
|
|
// FILE: A.java
|
|
@kotlin.jvm.PurelyImplements("kotlin.MutableCollection")
|
|
class A<T> extends AbstractCollection<T> {
|
|
@Override
|
|
public Iterator<T> iterator() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public int size() {
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
// FILE: b.kt
|
|
|
|
fun bar(): String? = null
|
|
|
|
fun foo() {
|
|
var x = A<String>()
|
|
x.add(<!NULL_FOR_NONNULL_TYPE!>null<!>)
|
|
x.add(<!TYPE_MISMATCH!>bar()<!>)
|
|
x.add("")
|
|
|
|
val b1: Collection<String?> = x
|
|
val b2: MutableCollection<String?> = <!TYPE_MISMATCH!>x<!>
|
|
}
|