Skip to content

Commit 481bfba

Browse files
fzhinkinSpace Team
authored andcommitted
Revert "KT-31400 Add a contract for isArrayOf"
This reverts commit 71c4011.
1 parent 2df0043 commit 481bfba

File tree

3 files changed

+4
-20
lines changed

3 files changed

+4
-20
lines changed

core/reflection.jvm/src/kotlin/reflect/jvm/internal/calls/AnnotationConstructorCaller.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private fun Any?.transformKotlinToJvm(expectedType: Class<*>): Any? {
7272
is KClass<*> -> this.java
7373
is Array<*> -> when {
7474
this.isArrayOf<Class<*>>() -> return null
75-
this.isArrayOf<KClass<*>>() -> this.map(KClass<*>::java).toTypedArray()
75+
this.isArrayOf<KClass<*>>() -> (this as Array<KClass<*>>).map(KClass<*>::java).toTypedArray()
7676
else -> this
7777
}
7878
else -> this

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
package kotlin.jvm
99

10-
import kotlin.contracts.contract
1110
import kotlin.internal.InlineOnly
1211
import kotlin.jvm.internal.ClassBasedDeclarationContainer
1312
import kotlin.jvm.internal.Reflection
@@ -96,15 +95,11 @@ public inline val <T : Any> KClass<T>.javaClass: Class<KClass<T>>
9695
get() = (this as java.lang.Object).getClass() as Class<KClass<T>>
9796

9897
/**
99-
* Checks if the array can contain an element of type [T].
98+
* Checks if array can contain element of type [T].
10099
*/
101100
@Suppress("REIFIED_TYPE_PARAMETER_NO_INLINE")
102-
public fun <reified T : Any> Array<*>.isArrayOf(): Boolean {
103-
contract {
104-
returns(true) implies (this@isArrayOf is Array<T>)
105-
}
106-
return T::class.java.isAssignableFrom(this::class.java.componentType)
107-
}
101+
public fun <reified T : Any> Array<*>.isArrayOf(): Boolean =
102+
T::class.java.isAssignableFrom(this::class.java.componentType)
108103

109104
/**
110105
* Returns a [KClass] instance corresponding to the annotation type of this annotation.

libraries/stdlib/jvm/test/collections/CollectionJVMTest.kt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,6 @@ class CollectionJVMTest {
124124
}
125125
}
126126

127-
@Test fun isArrayOf() {
128-
val arr: Array<*> = arrayOf("smart")
129-
130-
if (arr.isArrayOf<String>()) {
131-
val str: String = arr[0]
132-
assertEquals("smart", str)
133-
} else {
134-
fail("Should not be reachable")
135-
}
136-
}
137-
138127
@Test fun toSortedSet() {
139128
val data = listOf("foo", "Foo", "bar")
140129
val set1 = data.toSortedSet()

0 commit comments

Comments
 (0)