[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
This commit is contained in:
Nikita Bobko
2023-10-18 10:56:37 +02:00
committed by Space Team
parent 8b03636b3b
commit 14029b0ebc
24 changed files with 91 additions and 77 deletions
-9
View File
@@ -846,15 +846,6 @@ public inline fun kotlin.Short.toUShort(): kotlin.UShort
@kotlin.internal.InlineOnly
public inline fun <T : kotlin.AutoCloseable?, R> T.use(block: (T) -> R): R
@kotlin.annotation.Retention(value = AnnotationRetention.SOURCE)
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.TYPEALIAS})
@kotlin.annotation.MustBeDocumented
@kotlin.ExperimentalMultiplatform
@kotlin.SinceKotlin(version = "1.9")
public final annotation class AllowDifferentMembersInActual : kotlin.Annotation {
public constructor AllowDifferentMembersInActual()
}
public interface Annotation {
}
@@ -12,7 +12,7 @@ package kotlin.collections
*
* @param E the type of elements contained in the collection. The collection is invariant in its element type.
*/
@AllowDifferentMembersInActual // New 'checkIsMutable', 'toJSON', etc. members are added compared to the expect declaration
@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
public actual abstract class AbstractMutableCollection<E> protected actual constructor() : AbstractCollection<E>(), MutableCollection<E> {
actual abstract override fun add(element: E): Boolean
@@ -57,6 +57,7 @@ public actual abstract class AbstractMutableCollection<E> protected actual const
}
}
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@Deprecated("Provided so that subclasses inherit this function", level = DeprecationLevel.HIDDEN)
@JsName("toJSON")
protected fun toJSON(): Any = this.toArray()
@@ -66,6 +67,7 @@ public actual abstract class AbstractMutableCollection<E> protected actual const
* This method is called every time when a mutating method is called on this mutable collection.
* Mutable collections that are built (frozen) must throw `UnsupportedOperationException`.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
internal open fun checkIsMutable(): Unit { }
}
@@ -17,8 +17,12 @@ package kotlin.collections
*
* @param E the type of elements contained in the list. The list is invariant in its element type.
*/
@AllowDifferentMembersInActual // New 'removeRange', 'checkIsMutable', etc. members are added compared to the expect declaration
@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
public actual abstract class AbstractMutableList<E> protected actual constructor() : AbstractMutableCollection<E>(), MutableList<E> {
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
protected var modCount: Int = 0
abstract override fun add(index: Int, element: E): Unit
@@ -82,6 +86,7 @@ public actual abstract class AbstractMutableList<E> protected actual constructor
/**
* Removes the range of elements from this list starting from [fromIndex] and ending with but not including [toIndex].
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
protected open fun removeRange(fromIndex: Int, toIndex: Int) {
val iterator = listIterator(fromIndex)
repeat(toIndex - fromIndex) {
@@ -18,10 +18,12 @@ package kotlin.collections
* @param K the type of map keys. The map is invariant in its key type.
* @param V the type of map values. The map is invariant in its value type.
*/
@AllowDifferentMembersInActual // New 'createKeysView', 'checkIsMutable', etc. members are added compared to the expect declaration
@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
public actual abstract class AbstractMutableMap<K, V> protected actual constructor() : AbstractMap<K, V>(), MutableMap<K, V> {
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
internal open fun createKeysView(): MutableSet<K> = HashMapKeysDefault(this)
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
internal open fun createValuesView(): MutableCollection<V> = HashMapValuesDefault(this)
private var keysView: MutableSet<K>? = null
@@ -66,5 +68,6 @@ public actual abstract class AbstractMutableMap<K, V> protected actual construct
* This method is called every time when a mutating method is called on this mutable map.
* Mutable maps that are built (frozen) must throw `UnsupportedOperationException`.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
internal open fun checkIsMutable() {}
}
@@ -9,7 +9,7 @@ package kotlin.collections
*
* @param E the type of elements contained in the set. The set is invariant in its element type.
*/
@AllowDifferentMembersInActual // New 'AbstractMutableCollection` supertype is added compared to the expect declaration
@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
public actual abstract class AbstractMutableSet<E> protected actual constructor() : AbstractMutableCollection<E>(), MutableSet<E> {
/**
@@ -28,5 +28,5 @@ package kotlin
@Suppress("NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS")
@SinceKotlin("1.3") public actual typealias ConcurrentModificationException = java.util.ConcurrentModificationException
@AllowDifferentMembersInActual // New 'reversed', 'thenComparing', etc. members are added compared to the expect declaration
@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
@SinceKotlin("1.1") public actual typealias Comparator<T> = java.util.Comparator<T>
@@ -7,7 +7,7 @@
package kotlin.text
@AllowDifferentMembersInActual // New 'append' members are added compared to the expect declaration
@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
@SinceKotlin("1.1") public actual typealias Appendable = java.lang.Appendable
@Suppress("ACTUAL_WITHOUT_EXPECT") // TODO: some supertypes are missing
@@ -13,7 +13,7 @@ import java.util.AbstractCollection
* @param E the type of elements contained in the collection. The collection is invariant in its element type.
*/
@SinceKotlin("1.1")
@AllowDifferentMembersInActual // New 'AbstractCollection` supertype is added compared to the expect declaration
@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
public actual abstract class AbstractMutableCollection<E> protected actual constructor() : MutableCollection<E>, AbstractCollection<E>() {
/**
* Adds the specified element to the collection.
@@ -13,7 +13,7 @@ import java.util.AbstractList
* @param E the type of elements contained in the list. The list is invariant in its element type.
*/
@SinceKotlin("1.1")
@AllowDifferentMembersInActual // New 'AbstractList` supertype is added compared to the expect declaration
@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
public actual abstract class AbstractMutableList<E> protected actual constructor() : MutableList<E>, AbstractList<E>() {
/**
* Replaces the element at the specified position in this list with the specified element.
@@ -16,7 +16,7 @@ import java.util.AbstractMap
* @param V the type of map values. The map is invariant in its value type.
*/
@SinceKotlin("1.1")
@AllowDifferentMembersInActual // New 'AbstractMap` supertype is added compared to the expect declaration
@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
public actual abstract class AbstractMutableMap<K, V> protected actual constructor() : MutableMap<K, V>, AbstractMap<K, V>() {
/**
* Associates the specified [value] with the specified [key] in the map.
@@ -13,7 +13,7 @@ import java.util.AbstractSet
* @param E the type of elements contained in the set. The set is invariant in its element type.
*/
@SinceKotlin("1.1")
@AllowDifferentMembersInActual // New 'AbstractSet` supertype is added compared to the expect declaration
@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
public actual abstract class AbstractMutableSet<E> protected actual constructor() : MutableSet<E>, AbstractSet<E>() {
/**
* Adds the specified element to the set.
@@ -10,7 +10,7 @@ package kotlin.reflect
*
* @param R return type of the callable.
*/
@AllowDifferentMembersInActual // New 'KAnnotatedElement` supertype is added compared to the expect declaration
@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
public actual interface KCallable<out R> : KAnnotatedElement {
/**
* The name of this callable as it was declared in the source code.
@@ -28,16 +28,19 @@ public actual interface KCallable<out R> : KAnnotatedElement {
* If this callable requires a `this` instance or an extension receiver parameter,
* they come first in the list in that order.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
public val parameters: List<KParameter>
/**
* The type of values returned by this callable.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
public val returnType: KType
/**
* The list of type parameters of this callable.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val typeParameters: List<KTypeParameter>
@@ -46,6 +49,7 @@ public actual interface KCallable<out R> : KAnnotatedElement {
* Throws an exception if the number of specified arguments is not equal to the size of [parameters],
* or if their types do not match the types of the parameters.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
public fun call(vararg args: Any?): R
/**
@@ -53,35 +57,41 @@ public actual interface KCallable<out R> : KAnnotatedElement {
* If a parameter is not found in the mapping and is not optional (as per [KParameter.isOptional]),
* or its type does not match the type of the provided value, an exception is thrown.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
public fun callBy(args: Map<KParameter, Any?>): R
/**
* Visibility of this callable, or `null` if its visibility cannot be represented in Kotlin.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val visibility: KVisibility?
/**
* `true` if this callable is `final`.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val isFinal: Boolean
/**
* `true` if this callable is `open`.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val isOpen: Boolean
/**
* `true` if this callable is `abstract`.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val isAbstract: Boolean
/**
* `true` if this is a suspending function.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.3")
public val isSuspend: Boolean
}
@@ -13,7 +13,7 @@ package kotlin.reflect
*
* @param T the type of the class.
*/
@AllowDifferentMembersInActual // KClass for JVM adds a lot of new members compared to the expect declaration
@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
public actual interface KClass<T : Any> : KDeclarationContainer, KAnnotatedElement, KClassifier {
/**
* The simple name of the class as it was declared in the source code,
@@ -31,21 +31,25 @@ public actual interface KClass<T : Any> : KDeclarationContainer, KAnnotatedEleme
* All functions and properties accessible in this class, including those declared in this class
* and all of its superclasses. Does not include constructors.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
override val members: Collection<KCallable<*>>
/**
* All constructors declared in this class.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
public val constructors: Collection<KFunction<T>>
/**
* All classes declared inside this class. This includes both inner and static nested classes.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
public val nestedClasses: Collection<KClass<*>>
/**
* The instance of the object declaration, or `null` if this class is not an object declaration.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
public val objectInstance: T?
/**
@@ -57,42 +61,49 @@ public actual interface KClass<T : Any> : KDeclarationContainer, KAnnotatedEleme
/**
* The list of type parameters of this class. This list does *not* include type parameters of outer classes.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val typeParameters: List<KTypeParameter>
/**
* The list of immediate supertypes of this class, in the order they are listed in the source code.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val supertypes: List<KType>
/**
* The list of the immediate subclasses if this class is a sealed class, or an empty list otherwise.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.3")
public val sealedSubclasses: List<KClass<out T>>
/**
* Visibility of this class, or `null` if its visibility cannot be represented in Kotlin.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val visibility: KVisibility?
/**
* `true` if this class is `final`.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val isFinal: Boolean
/**
* `true` if this class is `open`.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val isOpen: Boolean
/**
* `true` if this class is `abstract`.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val isAbstract: Boolean
@@ -101,6 +112,7 @@ public actual interface KClass<T : Any> : KDeclarationContainer, KAnnotatedEleme
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/sealed-classes.html)
* for more information.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val isSealed: Boolean
@@ -110,6 +122,7 @@ public actual interface KClass<T : Any> : KDeclarationContainer, KAnnotatedEleme
* [data object](https://kotlinlang.org/docs/object-declarations.html#data-objects)
* in the Kotlin language documentation.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val isData: Boolean
@@ -118,6 +131,7 @@ public actual interface KClass<T : Any> : KDeclarationContainer, KAnnotatedEleme
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/nested-classes.html#inner-classes)
* for more information.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val isInner: Boolean
@@ -126,18 +140,21 @@ public actual interface KClass<T : Any> : KDeclarationContainer, KAnnotatedEleme
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/object-declarations.html#companion-objects)
* for more information.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val isCompanion: Boolean
/**
* `true` if this class is a Kotlin functional interface.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.4")
public val isFun: Boolean
/**
* `true` if this class is a value class.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.5")
public val isValue: Boolean
@@ -8,13 +8,14 @@ package kotlin.reflect
/**
* Represents a function with introspection capabilities.
*/
@AllowDifferentMembersInActual // KFunction for JVM adds a lot of new members compared to the expect declaration
@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
public actual interface KFunction<out R> : KCallable<R>, Function<R> {
/**
* `true` if this function is `inline`.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/inline-functions.html)
* for more information.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val isInline: Boolean
@@ -23,6 +24,7 @@ public actual interface KFunction<out R> : KCallable<R>, Function<R> {
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/java-interop.html#using-jni-with-kotlin)
* for more information.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val isExternal: Boolean
@@ -31,6 +33,7 @@ public actual interface KFunction<out R> : KCallable<R>, Function<R> {
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/operator-overloading.html)
* for more information.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val isOperator: Boolean
@@ -39,6 +42,7 @@ public actual interface KFunction<out R> : KCallable<R>, Function<R> {
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/functions.html#infix-notation)
* for more information.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val isInfix: Boolean
@@ -15,13 +15,14 @@ package kotlin.reflect
*
* @param V the type of the property value.
*/
@AllowDifferentMembersInActual // KProperty for JVM adds new members compared to the expect declaration
@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
public actual interface KProperty<out V> : KCallable<V> {
/**
* `true` if this property is `lateinit`.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/properties.html#late-initialized-properties)
* for more information.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val isLateinit: Boolean
@@ -30,10 +31,12 @@ public actual interface KProperty<out V> : KCallable<V> {
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/properties.html#compile-time-constants)
* for more information.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public val isConst: Boolean
/** The getter of this property, used to obtain the value of the property. */
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
public val getter: Getter<V>
/**
@@ -57,9 +60,10 @@ public actual interface KProperty<out V> : KCallable<V> {
/**
* Represents a property declared as a `var`.
*/
@AllowDifferentMembersInActual // New 'setter' member is added compared to the expect declaration
@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
public actual interface KMutableProperty<V> : KProperty<V> {
/** The setter of this mutable property, used to change the value of the property. */
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
public val setter: Setter<V>
/**
@@ -74,7 +78,7 @@ public actual interface KMutableProperty<V> : KProperty<V> {
* Such property is either originally declared in a receiverless context such as a package,
* or has the receiver bound to it.
*/
@AllowDifferentMembersInActual // New 'getDelegate' and 'getter' members are added compared to the expect declaration
@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
public actual interface KProperty0<out V> : KProperty<V>, () -> V {
/**
* Returns the current value of the property.
@@ -86,9 +90,11 @@ public actual interface KProperty0<out V> : KProperty<V>, () -> V {
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/delegated-properties.html)
* for more information.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public fun getDelegate(): Any?
@Suppress("RETURN_TYPE_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING") // Covariant 'setter' override. The suppress can be dropped in K2 KT-61184
override val getter: Getter<V>
/**
@@ -102,7 +108,7 @@ public actual interface KProperty0<out V> : KProperty<V>, () -> V {
/**
* Represents a `var`-property without any kind of receiver.
*/
@AllowDifferentMembersInActual // Covariant 'setter' override. The annotations can be dropped in K2 KT-61184
@Suppress("ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_MEMBERS_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING") // Covariant 'setter' override. The suppress can be dropped in K2 KT-61184
public actual interface KMutableProperty0<V> : KProperty0<V>, KMutableProperty<V> {
/**
* Modifies the value of the property.
@@ -111,6 +117,7 @@ public actual interface KMutableProperty0<V> : KProperty0<V>, KMutableProperty<V
*/
public actual fun set(value: V)
@Suppress("RETURN_TYPE_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING") // Covariant 'setter' override. The suppress can be dropped in K2 KT-61184
override val setter: Setter<V>
/**
@@ -128,7 +135,7 @@ public actual interface KMutableProperty0<V> : KProperty0<V>, KMutableProperty<V
* @param T the type of the receiver which should be used to obtain the value of the property.
* @param V the type of the property value.
*/
@AllowDifferentMembersInActual // New 'getDelegate' and 'getter' members are added compared to the expect declaration
@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
public actual interface KProperty1<T, out V> : KProperty<V>, (T) -> V {
/**
* Returns the current value of the property.
@@ -153,9 +160,11 @@ public actual interface KProperty1<T, out V> : KProperty<V>, (T) -> V {
*
* @see [kotlin.reflect.full.getExtensionDelegate] // [KProperty1.getExtensionDelegate]
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public fun getDelegate(receiver: T): Any?
@Suppress("RETURN_TYPE_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING") // Covariant 'getter' override. The suppress can be dropped in K2 KT-61184
override val getter: Getter<T, V>
/**
@@ -169,7 +178,7 @@ public actual interface KProperty1<T, out V> : KProperty<V>, (T) -> V {
/**
* Represents a `var`-property, operations on which take one receiver as a parameter.
*/
@AllowDifferentMembersInActual // Covariant 'setter' override. The annotations can be dropped in K2 KT-61184
@Suppress("ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_MEMBERS_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING") // Covariant 'setter' override. The suppress can be dropped in K2 KT-61184
public actual interface KMutableProperty1<T, V> : KProperty1<T, V>, KMutableProperty<V> {
/**
* Modifies the value of the property.
@@ -181,6 +190,7 @@ public actual interface KMutableProperty1<T, V> : KProperty1<T, V>, KMutableProp
*/
public actual fun set(receiver: T, value: V)
@Suppress("RETURN_TYPE_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING") // Covariant 'setter' override. The suppress can be dropped in K2 KT-61184
override val setter: Setter<T, V>
/**
@@ -202,7 +212,7 @@ public actual interface KMutableProperty1<T, V> : KProperty1<T, V>, KMutableProp
* the type of the extension receiver.
* @param V the type of the property value.
*/
@AllowDifferentMembersInActual // New 'getDelegate' and 'getter' members are added compared to the expect declaration
@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
public actual interface KProperty2<D, E, out V> : KProperty<V>, (D, E) -> V {
/**
* Returns the current value of the property. In case of the extension property in a class,
@@ -226,9 +236,11 @@ public actual interface KProperty2<D, E, out V> : KProperty<V>, (D, E) -> V {
*
* @see [kotlin.reflect.full.getExtensionDelegate] // [KProperty2.getExtensionDelegate]
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
@SinceKotlin("1.1")
public fun getDelegate(receiver1: D, receiver2: E): Any?
@Suppress("RETURN_TYPE_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING") // Covariant 'getter' override. The suppress can be dropped in K2 KT-61184
override val getter: Getter<D, E, V>
/**
@@ -243,7 +255,7 @@ public actual interface KProperty2<D, E, out V> : KProperty<V>, (D, E) -> V {
/**
* Represents a `var`-property, operations on which take two receivers as parameters.
*/
@AllowDifferentMembersInActual // Covariant 'setter' override. The annotations can be dropped in K2 KT-61184
@Suppress("ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_MEMBERS_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING") // Covariant 'setter' override. The suppress can be dropped in K2 KT-61184
public actual interface KMutableProperty2<D, E, V> : KProperty2<D, E, V>, KMutableProperty<V> {
/**
* Modifies the value of the property.
@@ -254,6 +266,7 @@ public actual interface KMutableProperty2<D, E, V> : KProperty2<D, E, V>, KMutab
*/
public actual fun set(receiver1: D, receiver2: E, value: V)
@Suppress("RETURN_TYPE_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING") // Covariant 'setter' override. The suppress can be dropped in K2 KT-61184
override val setter: Setter<D, E, V>
/**
@@ -9,7 +9,7 @@ package kotlin.reflect
* Represents a type. Type is usually either a class with optional type arguments,
* or a type parameter of some declaration, plus nullability.
*/
@AllowDifferentMembersInActual // New 'KAnnotatedElement` supertype is added compared to the expect declaration
@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
public actual interface KType : KAnnotatedElement {
/**
* The declaration of the classifier used in this type.
@@ -10,7 +10,7 @@ package kotlin.collections
*
* @param E the type of elements contained in the collection. The collection is invariant in its element type.
*/
@AllowDifferentMembersInActual // New 'AbstractCollection` supertype is added compared to the expect declaration
@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
public actual abstract class AbstractMutableCollection<E> protected actual constructor(): MutableCollection<E>, AbstractCollection<E>() {
// Bulk Modification Operations
@@ -17,7 +17,10 @@ package kotlin.collections
*
* @param E the type of elements contained in the list. The list is invariant in its element type.
*/
@AllowDifferentMembersInActual // New 'removeRange', 'modCount' members are added compared to the expect declaration
@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
public actual abstract class AbstractMutableList<E> protected actual constructor() : AbstractMutableCollection<E>(), MutableList<E> {
/**
* The number of times this list is structurally modified.
@@ -29,6 +32,7 @@ public actual abstract class AbstractMutableList<E> protected actual constructor
* to provide fail-fast behavoir when a concurrent modification is detected during iteration.
* [ConcurrentModificationException] will be thrown in this case.
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
protected var modCount: Int = 0
abstract override fun add(index: Int, element: E): Unit
@@ -82,6 +86,7 @@ public actual abstract class AbstractMutableList<E> protected actual constructor
/**
* Removes the range of elements from this list starting from [fromIndex] and ending with but not including [toIndex].
*/
@Suppress("NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING") // Can be dropped after bootstrap update
protected open fun removeRange(fromIndex: Int, toIndex: Int) {
val iterator = listIterator(fromIndex)
repeat(toIndex - fromIndex) {
@@ -8,7 +8,7 @@ package kotlin.collections
* @param K the type of map keys. The map is invariant in its key type.
* @param V the type of map values. The map is invariant in its value type.
*/
@AllowDifferentMembersInActual // New 'AbstractMap` supertype is added compared to the expect declaration
@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
@SinceKotlin("1.1")
public actual abstract class AbstractMutableMap<K, V> protected actual constructor() : AbstractMap<K, V>(), MutableMap<K, V> {
/**
@@ -5,7 +5,7 @@ package kotlin.collections
*
* @param E the type of elements contained in the set. The set is invariant in its element type.
*/
@AllowDifferentMembersInActual // New 'AbstractMutableCollection` supertype is added compared to the expect declaration
@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
@SinceKotlin("1.1")
public actual abstract class AbstractMutableSet<E> protected actual constructor() : AbstractMutableCollection<E>(), MutableSet<E> {
/**
@@ -1,37 +0,0 @@
package kotlin
import kotlin.annotation.AnnotationTarget.*
/**
* Kotlin reports a compilation error for cases when non-final `expect class` and its counterpart `actual class` have different set of
* non-private members (e.g. when a new member declared in `actual class` that wasn't presented in its `expect class`, or when
* modality is different).
*
* By marking `actual class` with this annotation, you suppress the compilation error mentioned above.
*
* ## Safety Risks
*
* Using this annotation causes undefined behaviour, it's not known what can break because of that. Be prepared that at some point this
* annotation might become deprecated, and you'd need to migrate your code.
*
* If you use this annotation and can't migrate, consider describing your use cases in
* [KT-22841](https://youtrack.jetbrains.com/issue/KT-22841) comments.
*
* ## Migration
*
* Please consider the following alternatives:
* - Make members in `expect class` and `actual class` the same
* - If the member was declared only in `actual class` then you'd need to declare it in the `expect class` as well
* - If the member is already declared in the `expect class` then make sure that the member is the same in the `actual class` (modality is
* the same, visibility is the same, return type is the same, etc.)
* - Make the `expect class` `final`. You might need to rewrite your code to use composition instead of inheritance.
* - Mark the members under the question as `private`
*
* [AllowDifferentMembersInActual] is supposed to be used for the transition period.
*/
@Retention(AnnotationRetention.SOURCE)
@Target(CLASS, TYPEALIAS)
@MustBeDocumented
@ExperimentalMultiplatform
@SinceKotlin("1.9")
public annotation class AllowDifferentMembersInActual