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
This commit is contained in:
Denis.Zharkov
2023-07-28 13:58:52 +02:00
committed by Space Team
parent d99f8ac9b4
commit 1e86a82ee1
8 changed files with 216 additions and 28 deletions
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// ISSUE: KT-58371
// WITH_STDLIB
@@ -11,8 +10,8 @@ class A<T> : ArrayList<T>() {
super.addLast(t)
}
override fun getFirst(): T = super.getFirst()
override fun getLast(): T = super.getLast()
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()
@@ -21,27 +20,39 @@ class A<T> : ArrayList<T>() {
}
fun foo(x: MutableList<String>, y: ArrayList<String>, z: A<String>) {
x.<!UNRESOLVED_REFERENCE!>addFirst<!>("")
x.<!UNRESOLVED_REFERENCE!>addLast<!>("")
x.<!UNRESOLVED_REFERENCE!>getFirst<!>()
x.<!UNRESOLVED_REFERENCE!>getLast<!>()
x.<!DEBUG_INFO_CALL("fqName: kotlin.collections.removeFirst; typeCall: extension function")!>removeFirst()<!>
x.<!DEBUG_INFO_CALL("fqName: kotlin.collections.removeLast; typeCall: extension function")!>removeLast()<!>
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.<!UNRESOLVED_REFERENCE!>addFirst<!>("")
y.<!UNRESOLVED_REFERENCE!>addLast<!>("")
y.<!UNRESOLVED_REFERENCE!>getFirst<!>()
y.<!UNRESOLVED_REFERENCE!>getLast<!>()
y.<!DEBUG_INFO_CALL("fqName: kotlin.collections.removeFirst; typeCall: extension function")!>removeFirst()<!>
y.<!DEBUG_INFO_CALL("fqName: kotlin.collections.removeLast; typeCall: extension function")!>removeLast()<!>
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.<!UNRESOLVED_REFERENCE!>addFirst<!>("")
z.<!UNRESOLVED_REFERENCE!>addLast<!>("")
z.<!UNRESOLVED_REFERENCE!>getFirst<!>()
z.<!UNRESOLVED_REFERENCE!>getLast<!>()
z.<!DEBUG_INFO_CALL("fqName: kotlin.collections.removeFirst; typeCall: extension function")!>removeFirst()<!>
z.<!DEBUG_INFO_CALL("fqName: kotlin.collections.removeLast; typeCall: extension function")!>removeLast()<!>
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()<!>
}