Replace is Array<T> with .isArrayOf<T>()

This commit is contained in:
Alexey Tsvetkov
2015-10-09 21:22:19 +03:00
parent 01cd277d63
commit 62c25c0370
19 changed files with 114 additions and 44 deletions
@@ -0,0 +1,26 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.jvm
import kotlin.jvm.internal.Intrinsic
/**
* Checks if array can contain element of type [T].
*/
@Intrinsic("kotlin.jvm.isArrayOf")
public fun <reified T : Any> Array<*>.isArrayOf(): Boolean =
T::class.java.isAssignableFrom(this.javaClass.componentType)
@@ -123,7 +123,7 @@ class CollectionJVMTest {
assertEquals(2, arr.size())
todo {
assertTrue {
arr is Array<String>
arr.isArrayOf<String>()
}
}
}
@@ -403,7 +403,7 @@ class CollectionTest {
assertEquals(2, arr.size())
todo {
assertTrue {
arr is Array<String>
arr.isArrayOf<String>()
}
}
}