diff --git a/compiler/testData/diagnostics/testsWithJdk21/implementationsForSequencedCollection.kt b/compiler/testData/diagnostics/testsWithJdk21/implementationsForSequencedCollection.kt index 0eeb0376861d4..fad0cf8d7875c 100644 --- a/compiler/testData/diagnostics/testsWithJdk21/implementationsForSequencedCollection.kt +++ b/compiler/testData/diagnostics/testsWithJdk21/implementationsForSequencedCollection.kt @@ -3,11 +3,11 @@ fun foo(ll: java.util.LinkedList, al: ArrayList, ad: ArrayDeque, jad: java.util.ArrayDeque) { ll.addFirst("") ll.addLast("") - ll.getFirst() - ll.first // synthetic property for getFirst() + ll.getFirst() + ll.first // synthetic property for getFirst() ll.first() // stdlib extension on List - ll.getLast() - ll.last + ll.getLast() + ll.last ll.last() ll.removeFirst() ll.removeLast() @@ -15,11 +15,11 @@ fun foo(ll: java.util.LinkedList, al: ArrayList, ad: ArrayDeque< al.addFirst("") al.addLast("") - al.getFirst() - al.first + al.getFirst() + al.first al.first() - al.getLast() - al.last + al.getLast() + al.last al.last() al.removeFirst() al.removeLast() @@ -27,11 +27,11 @@ fun foo(ll: java.util.LinkedList, al: ArrayList, ad: ArrayDeque< ad.addFirst("") ad.addLast("") - ad.getFirst() - ad.first + ad.getFirst() + ad.first ad.first() - ad.getLast() - ad.last + ad.getLast() + ad.last ad.last() ad.removeFirst() ad.removeLast() diff --git a/compiler/testData/diagnostics/testsWithJdk21/newListMethods.diag.txt b/compiler/testData/diagnostics/testsWithJdk21/newListMethods.diag.txt index 979104a128c80..9f01772ab9cba 100644 --- a/compiler/testData/diagnostics/testsWithJdk21/newListMethods.diag.txt +++ b/compiler/testData/diagnostics/testsWithJdk21/newListMethods.diag.txt @@ -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 - ^ + diff --git a/compiler/testData/diagnostics/testsWithJdk21/newListMethods.kt b/compiler/testData/diagnostics/testsWithJdk21/newListMethods.kt index 2bc052119b7c9..61c4bb763c320 100644 --- a/compiler/testData/diagnostics/testsWithJdk21/newListMethods.kt +++ b/compiler/testData/diagnostics/testsWithJdk21/newListMethods.kt @@ -11,8 +11,8 @@ class A : ArrayList() { super.addLast(t) } - override fun getFirst(): T = super.getFirst() - override fun getLast(): T = super.getLast() + override fun getFirst(): T = super.getFirst() + override fun getLast(): T = super.getLast() override fun removeFirst(): T = super.removeFirst() override fun removeLast(): T = super.removeLast() @@ -23,11 +23,11 @@ class A : ArrayList() { fun foo(x: MutableList, y: ArrayList, z: A) { x.addFirst("") x.addLast("") - x.getFirst() - x.first // synthetic property for getFirst() + x.getFirst() + x.first // synthetic property for getFirst() x.first() // stdlib extension on List - x.getLast() - x.last + x.getLast() + x.last x.last() x.removeFirst() x.removeLast() @@ -35,11 +35,11 @@ fun foo(x: MutableList, y: ArrayList, z: A) { y.addFirst("") y.addLast("") - y.getFirst() - y.first + y.getFirst() + y.first y.first() - y.getLast() - y.last + y.getLast() + y.last y.last() y.removeFirst() y.removeLast() @@ -47,11 +47,11 @@ fun foo(x: MutableList, y: ArrayList, z: A) { z.addFirst("") z.addLast("") - z.getFirst() - z.first + z.getFirst() + z.first z.first() - z.getLast() - z.last + z.getLast() + z.last z.last() z.removeFirst() z.removeLast() diff --git a/compiler/testData/diagnostics/testsWithJdk21/newListMethodsImmutable.kt b/compiler/testData/diagnostics/testsWithJdk21/newListMethodsImmutable.kt index 4118b69d375b8..977b86aade9b2 100644 --- a/compiler/testData/diagnostics/testsWithJdk21/newListMethodsImmutable.kt +++ b/compiler/testData/diagnostics/testsWithJdk21/newListMethodsImmutable.kt @@ -6,10 +6,10 @@ fun bar(x: List) { x.addLast("") x.removeFirst() x.removeLast() - x.getFirst() - x.getLast() - x.first - x.last + x.getFirst() + x.getLast() + x.first + x.last } // Additional test for other SequenceCollection inheritor @@ -18,10 +18,10 @@ fun baz(x: ArrayDeque, y: LinkedHashSet) { x.addLast("") x.removeFirst() x.removeLast() - x.getFirst() - x.getLast() - x.first - x.last + x.getFirst() + x.getLast() + x.first + x.last y.addFirst("") y.addLast("") diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/builtins/jvm/JvmBuiltInsCustomizer.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/builtins/jvm/JvmBuiltInsCustomizer.kt index b09f7ee80dfed..b42b0097d5cae 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/builtins/jvm/JvmBuiltInsCustomizer.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/builtins/jvm/JvmBuiltInsCustomizer.kt @@ -79,7 +79,8 @@ class JvmBuiltInsCustomizer( storageManager.createMemoizedFunction, 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))