Skip to content

Commit

Permalink
K1: change depr. level of List.getFirst to HIDDEN but don't force it …
Browse files Browse the repository at this point in the history
…on overrides

#KT-65441 Fixed

(cherry picked from commit 91e9fbd)
  • Loading branch information
mglukhikh authored and qodana-bot committed Feb 29, 2024
1 parent c041815 commit d3b2c6f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@
fun foo(ll: java.util.LinkedList<String>, al: ArrayList<String>, ad: ArrayDeque<String>, jad: java.util.ArrayDeque<String>) {
ll.addFirst("")
ll.addLast("")
ll.<!DEPRECATION!>getFirst<!>()
ll.<!DEPRECATION!>first<!> // synthetic property for getFirst()
ll.getFirst()
ll.first // synthetic property for getFirst()
ll.first() // stdlib extension on List
ll.<!DEPRECATION!>getLast<!>()
ll.<!DEPRECATION!>last<!>
ll.getLast()
ll.last
ll.last()
ll.<!DEBUG_INFO_CALL("fqName: java.util.LinkedList.removeFirst; typeCall: function")!>removeFirst()<!>
ll.<!DEBUG_INFO_CALL("fqName: java.util.LinkedList.removeLast; typeCall: function")!>removeLast()<!>
ll.<!DEBUG_INFO_CALL("fqName: kotlin.collections.reversed; typeCall: extension function")!>reversed()<!>

al.addFirst("")
al.addLast("")
al.<!DEPRECATION!>getFirst<!>()
al.<!DEPRECATION!>first<!>
al.getFirst()
al.first
al.first()
al.<!DEPRECATION!>getLast<!>()
al.<!DEPRECATION!>last<!>
al.getLast()
al.last
al.last()
al.<!DEBUG_INFO_CALL("fqName: java.util.ArrayList.removeFirst; typeCall: function")!>removeFirst()<!>
al.<!DEBUG_INFO_CALL("fqName: java.util.ArrayList.removeLast; typeCall: function")!>removeLast()<!>
al.<!DEBUG_INFO_CALL("fqName: kotlin.collections.reversed; typeCall: extension function")!>reversed()<!>

ad.addFirst("")
ad.addLast("")
ad.<!DEPRECATION!>getFirst<!>()
ad.<!DEPRECATION!>first<!>
ad.<!UNRESOLVED_REFERENCE!>getFirst<!>()
ad.<!DEPRECATION_ERROR!>first<!>
ad.first()
ad.<!DEPRECATION!>getLast<!>()
ad.<!DEPRECATION!>last<!>
ad.<!UNRESOLVED_REFERENCE!>getLast<!>()
ad.<!DEPRECATION_ERROR!>last<!>
ad.last()
ad.<!DEBUG_INFO_CALL("fqName: kotlin.collections.ArrayDeque.removeFirst; typeCall: function")!>removeFirst()<!>
ad.<!DEBUG_INFO_CALL("fqName: kotlin.collections.ArrayDeque.removeLast; typeCall: function")!>removeLast()<!>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,13 @@
/newListMethods.kt:14:18: warning: this declaration overrides deprecated member but not marked as deprecated itself. Please add @Deprecated annotation or suppress. See https://youtrack.jetbrains.com/issue/KT-47902 for details
override fun getFirst(): T = super.getFirst()
^
/newListMethods.kt:14:40: warning: 'getFirst(): E!' is deprecated. Overrides deprecated member in 'java.util.AbstractList'. 'getFirst()' member of List is redundant in Kotlin and might be removed soon. Please use 'first()' stdlib extension instead
override fun getFirst(): T = super.getFirst()
^
/newListMethods.kt:15:18: warning: this declaration overrides deprecated member but not marked as deprecated itself. Please add @Deprecated annotation or suppress. See https://youtrack.jetbrains.com/issue/KT-47902 for details
override fun getLast(): T = super.getLast()
^
/newListMethods.kt:15:39: warning: 'getLast(): E!' is deprecated. Overrides deprecated member in 'java.util.AbstractList'. 'getLast()' member of List is redundant in Kotlin and might be removed soon. Please use 'last()' stdlib extension instead
override fun getLast(): T = super.getLast()
^
/newListMethods.kt:26:7: warning: 'getFirst(): E!' is deprecated. 'getFirst()' member of List is redundant in Kotlin and might be removed soon. Please use 'first()' stdlib extension instead
/newListMethods.kt:26:7: error: unresolved reference: getFirst
x.getFirst()
^
/newListMethods.kt:27:7: warning: 'getter for first: E!' is deprecated. 'getFirst()' member of List is redundant in Kotlin and might be removed soon. Please use 'first()' stdlib extension instead
/newListMethods.kt:27:7: error: using 'getter for first: E!' is an error. 'getFirst()' member of List is redundant in Kotlin and might be removed soon. Please use 'first()' stdlib extension instead
x.first // synthetic property for getFirst()
^
/newListMethods.kt:29:7: warning: 'getLast(): E!' is deprecated. 'getLast()' member of List is redundant in Kotlin and might be removed soon. Please use 'last()' stdlib extension instead
/newListMethods.kt:29:7: error: unresolved reference: getLast
x.getLast()
^
/newListMethods.kt:30:7: warning: 'getter for last: E!' is deprecated. 'getLast()' member of List is redundant in Kotlin and might be removed soon. Please use 'last()' stdlib extension instead
/newListMethods.kt:30:7: error: using 'getter for last: E!' is an error. 'getLast()' member of List is redundant in Kotlin and might be removed soon. Please use 'last()' stdlib extension instead
x.last
^
/newListMethods.kt:38:7: warning: 'getFirst(): E!' is deprecated. Overrides deprecated member in 'java.util.AbstractList'. 'getFirst()' member of List is redundant in Kotlin and might be removed soon. Please use 'first()' stdlib extension instead
y.getFirst()
^
/newListMethods.kt:39:7: warning: 'getFirst(): E!' is deprecated. Overrides deprecated member in 'java.util.AbstractList'. 'getFirst()' member of List is redundant in Kotlin and might be removed soon. Please use 'first()' stdlib extension instead
y.first
^
/newListMethods.kt:41:7: warning: 'getLast(): E!' is deprecated. Overrides deprecated member in 'java.util.AbstractList'. 'getLast()' member of List is redundant in Kotlin and might be removed soon. Please use 'last()' stdlib extension instead
y.getLast()
^
/newListMethods.kt:42:7: warning: 'getLast(): E!' is deprecated. Overrides deprecated member in 'java.util.AbstractList'. 'getLast()' member of List is redundant in Kotlin and might be removed soon. Please use 'last()' stdlib extension instead
y.last
^
/newListMethods.kt:50:7: warning: 'getFirst(): E!' is deprecated. Overrides deprecated member in 'java.util.AbstractList'. 'getFirst()' member of List is redundant in Kotlin and might be removed soon. Please use 'first()' stdlib extension instead
z.getFirst()
^
/newListMethods.kt:51:7: warning: 'getFirst(): E!' is deprecated. Overrides deprecated member in 'java.util.AbstractList'. 'getFirst()' member of List is redundant in Kotlin and might be removed soon. Please use 'first()' stdlib extension instead
z.first
^
/newListMethods.kt:53:7: warning: 'getLast(): E!' is deprecated. Overrides deprecated member in 'java.util.AbstractList'. 'getLast()' member of List is redundant in Kotlin and might be removed soon. Please use 'last()' stdlib extension instead
z.getLast()
^
/newListMethods.kt:54:7: warning: 'getLast(): E!' is deprecated. Overrides deprecated member in 'java.util.AbstractList'. 'getLast()' member of List is redundant in Kotlin and might be removed soon. Please use 'last()' stdlib extension instead
z.last
^

28 changes: 14 additions & 14 deletions compiler/testData/diagnostics/testsWithJdk21/newListMethods.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class A<T> : ArrayList<T>() {
super.addLast(t)
}

override fun <!OVERRIDE_DEPRECATION!>getFirst<!>(): T = super.<!DEPRECATION!>getFirst<!>()
override fun <!OVERRIDE_DEPRECATION!>getLast<!>(): T = super.<!DEPRECATION!>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()
Expand All @@ -23,35 +23,35 @@ class A<T> : ArrayList<T>() {
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.<!UNRESOLVED_REFERENCE!>getFirst<!>()
x.<!DEPRECATION_ERROR!>first<!> // synthetic property for getFirst()
x.first() // stdlib extension on List
x.<!DEPRECATION!>getLast<!>()
x.<!DEPRECATION!>last<!>
x.<!UNRESOLVED_REFERENCE!>getLast<!>()
x.<!DEPRECATION_ERROR!>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.<!DEPRECATION!>getFirst<!>()
y.<!DEPRECATION!>first<!>
y.getFirst()
y.first
y.first()
y.<!DEPRECATION!>getLast<!>()
y.<!DEPRECATION!>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()<!>
y.<!DEBUG_INFO_CALL("fqName: kotlin.collections.reversed; typeCall: extension function")!>reversed()<!>

z.addFirst("")
z.addLast("")
z.<!DEPRECATION!>getFirst<!>()
z.<!DEPRECATION!>first<!>
z.getFirst()
z.first
z.first()
z.<!DEPRECATION!>getLast<!>()
z.<!DEPRECATION!>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()<!>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ fun bar(x: List<String>) {
x.<!UNRESOLVED_REFERENCE!>addLast<!>("")
x.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>removeFirst<!>()
x.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>removeLast<!>()
x.<!DEPRECATION, JAVA_MODULE_DOES_NOT_EXPORT_PACKAGE!>getFirst<!>()
x.<!DEPRECATION, JAVA_MODULE_DOES_NOT_EXPORT_PACKAGE!>getLast<!>()
x.<!DEPRECATION!>first<!>
x.<!DEPRECATION!>last<!>
x.<!UNRESOLVED_REFERENCE!>getFirst<!>()
x.<!UNRESOLVED_REFERENCE!>getLast<!>()
x.<!DEPRECATION_ERROR!>first<!>
x.<!DEPRECATION_ERROR!>last<!>
}

// Additional test for other SequenceCollection inheritor
Expand All @@ -18,10 +18,10 @@ fun baz(x: ArrayDeque<String>, y: LinkedHashSet<String>) {
x.addLast("")
x.removeFirst()
x.removeLast()
x.<!DEPRECATION!>getFirst<!>()
x.<!DEPRECATION!>getLast<!>()
x.<!DEPRECATION!>first<!>
x.<!DEPRECATION!>last<!>
x.<!UNRESOLVED_REFERENCE!>getFirst<!>()
x.<!UNRESOLVED_REFERENCE!>getLast<!>()
x.<!DEPRECATION_ERROR!>first<!>
x.<!DEPRECATION_ERROR!>last<!>

y.addFirst("")
y.addLast("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class JvmBuiltInsCustomizer(
storageManager.createMemoizedFunction<Pair<String, String>, Annotations> { (methodName, extensionName) ->
val annotation = moduleDescriptor.builtIns.createDeprecatedAnnotation(
"'$methodName()' member of List is redundant in Kotlin and might be removed soon. Please use '$extensionName()' stdlib extension instead",
forcePropagationDeprecationToOverrides = true,
forcePropagationDeprecationToOverrides = false,
level = "HIDDEN",
replaceWith = "$extensionName()"
)
Annotations.create(listOf(annotation))
Expand Down

0 comments on commit d3b2c6f

Please sign in to comment.