Skip to content

Commit 882f468

Browse files
nikitabobkoSpace Team
authored and
Space Team
committed
[STDLIB] 1/2 Drop AllowDifferentMembersInActual from stdlib
^KT-62656 Fixed I blindly converted all `@AllowDifferentMembersInActual` to suppresses. But some suppresses in stdlib are redundant. I'm too lazy properly annotate only the necessary places. All these suppresses will go away after the bootstrap update anyway I drop allowDifferentMembersInActual_class and allowDifferentMembersInActual_typealias tests because their only purpose was to check that `@AllowDifferentMembersInActual` works as expected Note: some tests are failing in the compiler because of that. I will fix them in the next commit
1 parent 5cbfe24 commit 882f468

File tree

24 files changed

+91
-77
lines changed

24 files changed

+91
-77
lines changed

kotlin-native/runtime/src/main/kotlin/kotlin/reflect/KCallable.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ package kotlin.reflect
1010
*
1111
* @param R return type of the callable.
1212
*/
13-
@AllowDifferentMembersInActual // New 'KAnnotatedElement` supertype is added compared to the expect declaration
13+
@Suppress(
14+
"ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_SUPERTYPES_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING",
15+
"ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_MEMBERS_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING"
16+
) // Can be dropped after bootstrap update
1417
public actual interface KCallable<out R> : KAnnotatedElement {
1518
/**
1619
* The name of this callable as it was declared in the source code.
@@ -26,5 +29,6 @@ public actual interface KCallable<out R> : KAnnotatedElement {
2629
/**
2730
* The type of values returned by this callable.
2831
*/
32+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
2933
public val returnType: KType
3034
}

kotlin-native/runtime/src/main/kotlin/kotlin/reflect/KClass.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ package kotlin.reflect
1313
*
1414
* @param T the type of the class.
1515
*/
16-
@AllowDifferentMembersInActual // New 'KDeclarationContainer', 'KAnnotatedElement` supertypes are added compared to the expect declaration
16+
@Suppress("ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_SUPERTYPES_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING") // Can be dropped after bootstrap update
1717
public actual interface KClass<T : Any> : KDeclarationContainer, KAnnotatedElement, KClassifier {
1818
/**
1919
* The simple name of the class as it was declared in the source code,

libraries/stdlib/api/js/kotlin.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -846,15 +846,6 @@ public inline fun kotlin.Short.toUShort(): kotlin.UShort
846846
@kotlin.internal.InlineOnly
847847
public inline fun <T : kotlin.AutoCloseable?, R> T.use(block: (T) -> R): R
848848

849-
@kotlin.annotation.Retention(value = AnnotationRetention.SOURCE)
850-
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.TYPEALIAS})
851-
@kotlin.annotation.MustBeDocumented
852-
@kotlin.ExperimentalMultiplatform
853-
@kotlin.SinceKotlin(version = "1.9")
854-
public final annotation class AllowDifferentMembersInActual : kotlin.Annotation {
855-
public constructor AllowDifferentMembersInActual()
856-
}
857-
858849
public interface Annotation {
859850
}
860851

libraries/stdlib/js/src/kotlin/collections/AbstractMutableCollection.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ package kotlin.collections
1212
*
1313
* @param E the type of elements contained in the collection. The collection is invariant in its element type.
1414
*/
15-
@AllowDifferentMembersInActual // New 'checkIsMutable', 'toJSON', etc. members are added compared to the expect declaration
15+
@Suppress("ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_MEMBERS_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING", "ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_SUPERTYPES_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING") // Can be dropped after bootstrap update
1616
public actual abstract class AbstractMutableCollection<E> protected actual constructor() : AbstractCollection<E>(), MutableCollection<E> {
1717

1818
actual abstract override fun add(element: E): Boolean
@@ -57,6 +57,7 @@ public actual abstract class AbstractMutableCollection<E> protected actual const
5757
}
5858
}
5959

60+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
6061
@Deprecated("Provided so that subclasses inherit this function", level = DeprecationLevel.HIDDEN)
6162
@JsName("toJSON")
6263
protected fun toJSON(): Any = this.toArray()
@@ -66,6 +67,7 @@ public actual abstract class AbstractMutableCollection<E> protected actual const
6667
* This method is called every time when a mutating method is called on this mutable collection.
6768
* Mutable collections that are built (frozen) must throw `UnsupportedOperationException`.
6869
*/
70+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
6971
internal open fun checkIsMutable(): Unit { }
7072
}
7173

libraries/stdlib/js/src/kotlin/collections/AbstractMutableList.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ package kotlin.collections
1717
*
1818
* @param E the type of elements contained in the list. The list is invariant in its element type.
1919
*/
20-
@AllowDifferentMembersInActual // New 'removeRange', 'checkIsMutable', etc. members are added compared to the expect declaration
20+
@Suppress(
21+
"ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_MEMBERS_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING",
22+
"ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_SUPERTYPES_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING"
23+
) // Can be dropped after bootstrap update
2124
public actual abstract class AbstractMutableList<E> protected actual constructor() : AbstractMutableCollection<E>(), MutableList<E> {
25+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
2226
protected var modCount: Int = 0
2327

2428
abstract override fun add(index: Int, element: E): Unit
@@ -82,6 +86,7 @@ public actual abstract class AbstractMutableList<E> protected actual constructor
8286
/**
8387
* Removes the range of elements from this list starting from [fromIndex] and ending with but not including [toIndex].
8488
*/
89+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
8590
protected open fun removeRange(fromIndex: Int, toIndex: Int) {
8691
val iterator = listIterator(fromIndex)
8792
repeat(toIndex - fromIndex) {

libraries/stdlib/js/src/kotlin/collections/AbstractMutableMap.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ package kotlin.collections
1818
* @param K the type of map keys. The map is invariant in its key type.
1919
* @param V the type of map values. The map is invariant in its value type.
2020
*/
21-
@AllowDifferentMembersInActual // New 'createKeysView', 'checkIsMutable', etc. members are added compared to the expect declaration
21+
@Suppress("ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_MEMBERS_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING", "ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_SUPERTYPES_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING") // Can be dropped after bootstrap update
2222
public actual abstract class AbstractMutableMap<K, V> protected actual constructor() : AbstractMap<K, V>(), MutableMap<K, V> {
2323

24+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
2425
internal open fun createKeysView(): MutableSet<K> = HashMapKeysDefault(this)
26+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
2527
internal open fun createValuesView(): MutableCollection<V> = HashMapValuesDefault(this)
2628

2729
private var keysView: MutableSet<K>? = null
@@ -66,5 +68,6 @@ public actual abstract class AbstractMutableMap<K, V> protected actual construct
6668
* This method is called every time when a mutating method is called on this mutable map.
6769
* Mutable maps that are built (frozen) must throw `UnsupportedOperationException`.
6870
*/
71+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
6972
internal open fun checkIsMutable() {}
7073
}

libraries/stdlib/js/src/kotlin/collections/AbstractMutableSet.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package kotlin.collections
99
*
1010
* @param E the type of elements contained in the set. The set is invariant in its element type.
1111
*/
12-
@AllowDifferentMembersInActual // New 'AbstractMutableCollection` supertype is added compared to the expect declaration
12+
@Suppress("ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_MEMBERS_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING", "ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_SUPERTYPES_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING") // Can be dropped after bootstrap update
1313
public actual abstract class AbstractMutableSet<E> protected actual constructor() : AbstractMutableCollection<E>(), MutableSet<E> {
1414

1515
/**

libraries/stdlib/jvm/runtime/kotlin/TypeAliases.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ package kotlin
2828
@Suppress("NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS")
2929
@SinceKotlin("1.3") public actual typealias ConcurrentModificationException = java.util.ConcurrentModificationException
3030

31-
@AllowDifferentMembersInActual // New 'reversed', 'thenComparing', etc. members are added compared to the expect declaration
31+
@Suppress("ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_MEMBERS_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING", "ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_SUPERTYPES_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING") // Can be dropped after bootstrap update
3232
@SinceKotlin("1.1") public actual typealias Comparator<T> = java.util.Comparator<T>

libraries/stdlib/jvm/runtime/kotlin/text/TypeAliases.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
package kotlin.text
99

10-
@AllowDifferentMembersInActual // New 'append' members are added compared to the expect declaration
10+
@Suppress("ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_MEMBERS_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING", "ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_SUPERTYPES_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING") // Can be dropped after bootstrap update
1111
@SinceKotlin("1.1") public actual typealias Appendable = java.lang.Appendable
1212

1313
@Suppress("ACTUAL_WITHOUT_EXPECT") // TODO: some supertypes are missing

libraries/stdlib/jvm/src/kotlin/collections/AbstractMutableCollection.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import java.util.AbstractCollection
1313
* @param E the type of elements contained in the collection. The collection is invariant in its element type.
1414
*/
1515
@SinceKotlin("1.1")
16-
@AllowDifferentMembersInActual // New 'AbstractCollection` supertype is added compared to the expect declaration
16+
@Suppress("ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_MEMBERS_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING", "ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_SUPERTYPES_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING") // Can be dropped after bootstrap update
1717
public actual abstract class AbstractMutableCollection<E> protected actual constructor() : MutableCollection<E>, AbstractCollection<E>() {
1818
/**
1919
* Adds the specified element to the collection.

libraries/stdlib/jvm/src/kotlin/collections/AbstractMutableList.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import java.util.AbstractList
1313
* @param E the type of elements contained in the list. The list is invariant in its element type.
1414
*/
1515
@SinceKotlin("1.1")
16-
@AllowDifferentMembersInActual // New 'AbstractList` supertype is added compared to the expect declaration
16+
@Suppress("ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_MEMBERS_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING", "ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_SUPERTYPES_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING") // Can be dropped after bootstrap update
1717
public actual abstract class AbstractMutableList<E> protected actual constructor() : MutableList<E>, AbstractList<E>() {
1818
/**
1919
* Replaces the element at the specified position in this list with the specified element.

libraries/stdlib/jvm/src/kotlin/collections/AbstractMutableMap.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import java.util.AbstractMap
1616
* @param V the type of map values. The map is invariant in its value type.
1717
*/
1818
@SinceKotlin("1.1")
19-
@AllowDifferentMembersInActual // New 'AbstractMap` supertype is added compared to the expect declaration
19+
@Suppress("ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_MEMBERS_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING", "ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_SUPERTYPES_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING") // Can be dropped after bootstrap update
2020
public actual abstract class AbstractMutableMap<K, V> protected actual constructor() : MutableMap<K, V>, AbstractMap<K, V>() {
2121
/**
2222
* Associates the specified [value] with the specified [key] in the map.

libraries/stdlib/jvm/src/kotlin/collections/AbstractMutableSet.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import java.util.AbstractSet
1313
* @param E the type of elements contained in the set. The set is invariant in its element type.
1414
*/
1515
@SinceKotlin("1.1")
16-
@AllowDifferentMembersInActual // New 'AbstractSet` supertype is added compared to the expect declaration
16+
@Suppress("ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_MEMBERS_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING", "ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_SUPERTYPES_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING") // Can be dropped after bootstrap update
1717
public actual abstract class AbstractMutableSet<E> protected actual constructor() : MutableSet<E>, AbstractSet<E>() {
1818
/**
1919
* Adds the specified element to the set.

libraries/stdlib/jvm/src/kotlin/reflect/KCallable.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package kotlin.reflect
1010
*
1111
* @param R return type of the callable.
1212
*/
13-
@AllowDifferentMembersInActual // New 'KAnnotatedElement` supertype is added compared to the expect declaration
13+
@Suppress("ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_MEMBERS_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING", "ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_SUPERTYPES_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING") // Can be dropped after bootstrap update
1414
public actual interface KCallable<out R> : KAnnotatedElement {
1515
/**
1616
* The name of this callable as it was declared in the source code.
@@ -28,16 +28,19 @@ public actual interface KCallable<out R> : KAnnotatedElement {
2828
* If this callable requires a `this` instance or an extension receiver parameter,
2929
* they come first in the list in that order.
3030
*/
31+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
3132
public val parameters: List<KParameter>
3233

3334
/**
3435
* The type of values returned by this callable.
3536
*/
37+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
3638
public val returnType: KType
3739

3840
/**
3941
* The list of type parameters of this callable.
4042
*/
43+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
4144
@SinceKotlin("1.1")
4245
public val typeParameters: List<KTypeParameter>
4346

@@ -46,42 +49,49 @@ public actual interface KCallable<out R> : KAnnotatedElement {
4649
* Throws an exception if the number of specified arguments is not equal to the size of [parameters],
4750
* or if their types do not match the types of the parameters.
4851
*/
52+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
4953
public fun call(vararg args: Any?): R
5054

5155
/**
5256
* Calls this callable with the specified mapping of parameters to arguments and returns the result.
5357
* If a parameter is not found in the mapping and is not optional (as per [KParameter.isOptional]),
5458
* or its type does not match the type of the provided value, an exception is thrown.
5559
*/
60+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
5661
public fun callBy(args: Map<KParameter, Any?>): R
5762

5863
/**
5964
* Visibility of this callable, or `null` if its visibility cannot be represented in Kotlin.
6065
*/
66+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
6167
@SinceKotlin("1.1")
6268
public val visibility: KVisibility?
6369

6470
/**
6571
* `true` if this callable is `final`.
6672
*/
73+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
6774
@SinceKotlin("1.1")
6875
public val isFinal: Boolean
6976

7077
/**
7178
* `true` if this callable is `open`.
7279
*/
80+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
7381
@SinceKotlin("1.1")
7482
public val isOpen: Boolean
7583

7684
/**
7785
* `true` if this callable is `abstract`.
7886
*/
87+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
7988
@SinceKotlin("1.1")
8089
public val isAbstract: Boolean
8190

8291
/**
8392
* `true` if this is a suspending function.
8493
*/
94+
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
8595
@SinceKotlin("1.3")
8696
public val isSuspend: Boolean
8797
}

0 commit comments

Comments
 (0)