mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-14 00:21:34 +00:00
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
23 lines
427 B
Kotlin
Vendored
23 lines
427 B
Kotlin
Vendored
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
|
import java.util.*
|
|
|
|
fun bar(): String? = null
|
|
|
|
fun foo() {
|
|
var x = ArrayList<String?>()
|
|
x.add(null)
|
|
x.add(bar())
|
|
x.add("")
|
|
|
|
x[0] = null
|
|
x[0] = bar()
|
|
x[0] = ""
|
|
|
|
val b1: MutableList<String?> = x
|
|
val b2: MutableList<String> = <!TYPE_MISMATCH!>x<!>
|
|
val b3: List<String?> = x
|
|
|
|
val b4: Collection<String?> = x
|
|
val b6: MutableCollection<String?> = x
|
|
}
|