All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jsMain.internal.ConstructFromKClass.kt Maven / Gradle / Ivy

There is a newer version: 4.10.0-legacy-ie11
Show newest version
package pt.lightweightform.lfkotlin.internal

import kotlin.reflect.KClass

/** JavaScript's `Object` object. */
private external val Object: dynamic

/** Creates a Kotlin class instance given a [KClass] and the constructor arguments. */
internal fun  constructFromKClass(kClass: KClass, vararg arguments: Any?): T {
    // XXX: Work around not having access to `kClass.constructors` or to the `new` keyword
    val obj = Object.create(kClass.js.asDynamic().prototype)
    obj.constructor.apply(obj, arguments)
    return obj as T
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy