Files
kotlin-fork/compiler/testData/diagnostics/testsWithJdk21/newListMethods.kt
T
Denis.Zharkov 1e86a82ee1 K1: Change how Kotlin sees some of the new JDK 21 collections members
- Make addFirst/Last and removeFirst/removeLast as members
- Leave getFirst/getLast unprocessed, thus visible for K1, but marked
as deprecated

Though the implementations of getFirst/getLast and synthetic property
access to them are expected to be deprecated as well, it's expected
to be fixed in later commits.

^KT-60659 In Progress
^KT-60769 In Progress
2023-08-03 13:31:07 +00:00

59 lines
2.0 KiB
Kotlin
Vendored

// ISSUE: KT-58371
// WITH_STDLIB
class A<T> : ArrayList<T>() {
override fun addFirst(t: T) {
super.addFirst(t)
}
override fun addLast(t: T) {
super.addLast(t)
}
override fun <!OVERRIDE_DEPRECATION!>getFirst<!>(): T = super.getFirst()
override fun <!OVERRIDE_DEPRECATION!>getLast<!>(): T = super.getLast()
override fun removeFirst(): T = super.removeFirst()
override fun removeLast(): T = super.removeLast()
override fun reversed(): List<T> = super.reversed()
}
fun foo(x: MutableList<String>, y: ArrayList<String>, z: A<String>) {
x.addFirst("")
x.addLast("")
x.<!DEPRECATION!>getFirst<!>()
x.<!DEPRECATION!>first<!> // synthetic property for getFirst()
x.first() // stdlib extension on List
x.<!DEPRECATION!>getLast<!>()
x.<!DEPRECATION!>last<!>
x.last()
x.<!DEBUG_INFO_CALL("fqName: kotlin.collections.MutableList.removeFirst; typeCall: function")!>removeFirst()<!>
x.<!DEBUG_INFO_CALL("fqName: kotlin.collections.MutableList.removeLast; typeCall: function")!>removeLast()<!>
x.<!DEBUG_INFO_CALL("fqName: kotlin.collections.reversed; typeCall: extension function")!>reversed()<!>
y.addFirst("")
y.addLast("")
y.getFirst()
y.first
y.first()
y.getLast()
y.last
y.last()
y.<!DEBUG_INFO_CALL("fqName: java.util.ArrayList.removeFirst; typeCall: function")!>removeFirst()<!>
y.<!DEBUG_INFO_CALL("fqName: java.util.ArrayList.removeLast; typeCall: function")!>removeLast()<!>
y.<!DEBUG_INFO_CALL("fqName: kotlin.collections.reversed; typeCall: extension function")!>reversed()<!>
z.addFirst("")
z.addLast("")
z.getFirst()
z.first
z.first()
z.getLast()
z.last
z.last()
z.<!DEBUG_INFO_CALL("fqName: A.removeFirst; typeCall: function")!>removeFirst()<!>
z.<!DEBUG_INFO_CALL("fqName: A.removeLast; typeCall: function")!>removeLast()<!>
z.<!DEBUG_INFO_CALL("fqName: kotlin.collections.reversed; typeCall: extension function")!>reversed()<!>
}