K1: Implement a checker that disallows to have different member scopes for expect open and its actual
^KT-22841 Fixed Review: https://jetbrains.team/p/kt/reviews/11603/timeline The commit also introduces `@AllowDifferentMembersInActual` annotation in stdlib which allows to suppress the diagnostic
This commit is contained in:
@@ -28,4 +28,6 @@ package kotlin
|
||||
@Suppress("NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS")
|
||||
@SinceKotlin("1.3") public actual typealias ConcurrentModificationException = java.util.ConcurrentModificationException
|
||||
|
||||
@OptIn(ExperimentalMultiplatform::class)
|
||||
@AllowDifferentMembersInActual // New 'reversed', 'thenComparing', etc. members are added compared to the expect declaration
|
||||
@SinceKotlin("1.1") public actual typealias Comparator<T> = java.util.Comparator<T>
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
package kotlin.text
|
||||
|
||||
@OptIn(ExperimentalMultiplatform::class)
|
||||
@AllowDifferentMembersInActual // New 'append' members are added compared to the expect declaration
|
||||
@SinceKotlin("1.1") public actual typealias Appendable = java.lang.Appendable
|
||||
|
||||
@Suppress("ACTUAL_WITHOUT_EXPECT") // TODO: some supertypes are missing
|
||||
|
||||
@@ -13,6 +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
|
||||
public actual abstract class AbstractMutableCollection<E> protected actual constructor() : MutableCollection<E>, AbstractCollection<E>() {
|
||||
/**
|
||||
* Adds the specified element to the collection.
|
||||
|
||||
@@ -13,6 +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
|
||||
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,6 +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
|
||||
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,6 +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
|
||||
public actual abstract class AbstractMutableSet<E> protected actual constructor() : MutableSet<E>, AbstractSet<E>() {
|
||||
/**
|
||||
* Adds the specified element to the set.
|
||||
|
||||
@@ -10,6 +10,7 @@ package kotlin.reflect
|
||||
*
|
||||
* @param R return type of the callable.
|
||||
*/
|
||||
@AllowDifferentMembersInActual // New 'KAnnotatedElement` supertype is added compared to the expect declaration
|
||||
public actual interface KCallable<out R> : KAnnotatedElement {
|
||||
/**
|
||||
* The name of this callable as it was declared in the source code.
|
||||
|
||||
@@ -13,6 +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
|
||||
public actual interface KClass<T : Any> : KDeclarationContainer, KAnnotatedElement, KClassifier {
|
||||
/**
|
||||
* The simple name of the class as it was declared in the source code,
|
||||
@@ -151,7 +152,7 @@ public actual interface KClass<T : Any> : KDeclarationContainer, KAnnotatedEleme
|
||||
* For example, on JVM, [KClass] instances for a primitive type (`int`) and the corresponding wrapper type (`java.lang.Integer`)
|
||||
* are considered equal, because they have the same fully qualified name "kotlin.Int".
|
||||
*/
|
||||
override fun equals(other: Any?): Boolean
|
||||
actual override fun equals(other: Any?): Boolean // KT-24971
|
||||
|
||||
override fun hashCode(): Int
|
||||
actual override fun hashCode(): Int // KT-24971
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ package kotlin.reflect
|
||||
/**
|
||||
* Represents a function with introspection capabilities.
|
||||
*/
|
||||
@AllowDifferentMembersInActual // KFunction for JVM adds a lot of new members compared to the expect declaration
|
||||
public actual interface KFunction<out R> : KCallable<R>, Function<R> {
|
||||
/**
|
||||
* `true` if this function is `inline`.
|
||||
|
||||
@@ -15,6 +15,7 @@ package kotlin.reflect
|
||||
*
|
||||
* @param V the type of the property value.
|
||||
*/
|
||||
@AllowDifferentMembersInActual // KProperty for JVM adds new members compared to the expect declaration
|
||||
public actual interface KProperty<out V> : KCallable<V> {
|
||||
/**
|
||||
* `true` if this property is `lateinit`.
|
||||
@@ -56,6 +57,7 @@ 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
|
||||
public actual interface KMutableProperty<V> : KProperty<V> {
|
||||
/** The setter of this mutable property, used to change the value of the property. */
|
||||
public val setter: Setter<V>
|
||||
@@ -72,6 +74,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
|
||||
public actual interface KProperty0<out V> : KProperty<V>, () -> V {
|
||||
/**
|
||||
* Returns the current value of the property.
|
||||
@@ -99,6 +102,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
|
||||
public actual interface KMutableProperty0<V> : KProperty0<V>, KMutableProperty<V> {
|
||||
/**
|
||||
* Modifies the value of the property.
|
||||
@@ -124,6 +128,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
|
||||
public actual interface KProperty1<T, out V> : KProperty<V>, (T) -> V {
|
||||
/**
|
||||
* Returns the current value of the property.
|
||||
@@ -164,6 +169,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
|
||||
public actual interface KMutableProperty1<T, V> : KProperty1<T, V>, KMutableProperty<V> {
|
||||
/**
|
||||
* Modifies the value of the property.
|
||||
@@ -196,6 +202,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
|
||||
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,
|
||||
@@ -236,6 +243,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
|
||||
public actual interface KMutableProperty2<D, E, V> : KProperty2<D, E, V>, KMutableProperty<V> {
|
||||
/**
|
||||
* Modifies the value of the property.
|
||||
|
||||
@@ -9,6 +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
|
||||
public actual interface KType : KAnnotatedElement {
|
||||
/**
|
||||
* The declaration of the classifier used in this type.
|
||||
|
||||
Reference in New Issue
Block a user