https://kotlinlang.org logo
#javascript
Title
# javascript
e

Edoardo Luppi

12/12/2023, 10:07 AM
Is there any known issue, or cases where it isn't supported, with
KClass.isInstance(someObject)
in K/JS? Example usage:
Copy code
getKindOfOps<InsertBeforeOp>(rewrites, InsertBeforeOp::class, i)

...

private fun <T : RewriteOperation> getKindOfOps(
  rewrites: List<RewriteOperation?>,
  kind: KClass<*>,
  before: Int,
): List<T> {
  ...
  while (i < before && i < rewrites.size) {
    ...
    if (kind.isInstance(op)) {
      @Suppress("UNCHECKED_CAST")
      ops.add(op as T)
    }
  }
  return ops
}
a

Artem Kobzar

12/12/2023, 2:11 PM
No, it should work in runtime for both classes and interfaces.
e

Edoardo Luppi

12/12/2023, 2:13 PM
Perfect, thanks!