[FIR] By default, only hide members from mapped scope but not overrides

This affects methods like List.getFirst/getLast where it was decided
to keep them hidden but to make them visible on overrides like
ArrayList or LinkedList.
The goal is to prevent a breaking change since some implementations
like LinkedList had this method before JDK 21.

#KT-65438
This commit is contained in:
Kirill Rakhman
2024-02-02 18:20:47 +01:00
committed by Space Team
parent fbe8db4b45
commit fc6d25e50f
8 changed files with 45 additions and 50 deletions
@@ -1,11 +1,11 @@
fun foo(ll: java.util.LinkedList<String>, al: ArrayList<String>, ad: ArrayDeque<String>, jad: java.util.ArrayDeque<String>) {
ll.addFirst("")
ll.addLast("")
ll.<!UNRESOLVED_REFERENCE!>getFirst<!>()
ll.<!INVISIBLE_REFERENCE!>first<!> // synthetic property for getFirst()
ll.getFirst()
ll.first // synthetic property for getFirst()
ll.first() // stdlib extension on List
ll.<!UNRESOLVED_REFERENCE!>getLast<!>()
ll.<!INVISIBLE_REFERENCE!>last<!>
ll.getLast()
ll.last
ll.last()
ll.removeFirst()
ll.removeLast()
@@ -13,11 +13,11 @@ fun foo(ll: java.util.LinkedList<String>, al: ArrayList<String>, ad: ArrayDeque<
al.addFirst("")
al.addLast("")
al.<!UNRESOLVED_REFERENCE!>getFirst<!>()
al.<!FUNCTION_CALL_EXPECTED!>first<!>
al.getFirst()
al.first
al.first()
al.<!UNRESOLVED_REFERENCE!>getLast<!>()
al.<!FUNCTION_CALL_EXPECTED!>last<!>
al.getLast()
al.last
al.last()
al.removeFirst()
al.removeLast()
@@ -5,19 +5,3 @@
/newListMethods.fir.kt:(704,711): error: Unresolved reference 'getLast'.
/newListMethods.fir.kt:(720,724): error: Function invocation 'last()' expected.
/newListMethods.fir.kt:(838,846): error: Unresolved reference 'getFirst'.
/newListMethods.fir.kt:(855,860): error: Function invocation 'first()' expected.
/newListMethods.fir.kt:(881,888): error: Unresolved reference 'getLast'.
/newListMethods.fir.kt:(897,901): error: Function invocation 'last()' expected.
/newListMethods.fir.kt:(1015,1023): error: Unresolved reference 'getFirst'.
/newListMethods.fir.kt:(1032,1037): error: Function invocation 'first()' expected.
/newListMethods.fir.kt:(1058,1065): error: Unresolved reference 'getLast'.
/newListMethods.fir.kt:(1074,1078): error: Function invocation 'last()' expected.
@@ -34,11 +34,11 @@ fun foo(x: MutableList<String>, y: ArrayList<String>, z: A<String>) {
y.addFirst("")
y.addLast("")
y.<!UNRESOLVED_REFERENCE!>getFirst<!>()
y.<!FUNCTION_CALL_EXPECTED!>first<!>
y.getFirst()
y.first
y.first()
y.<!UNRESOLVED_REFERENCE!>getLast<!>()
y.<!FUNCTION_CALL_EXPECTED!>last<!>
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()<!>
@@ -46,11 +46,11 @@ fun foo(x: MutableList<String>, y: ArrayList<String>, z: A<String>) {
z.addFirst("")
z.addLast("")
z.<!UNRESOLVED_REFERENCE!>getFirst<!>()
z.<!FUNCTION_CALL_EXPECTED!>first<!>
z.getFirst()
z.first
z.first()
z.<!UNRESOLVED_REFERENCE!>getLast<!>()
z.<!FUNCTION_CALL_EXPECTED!>last<!>
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()<!>