JS: fix class literal expression with primitive classes. See KT-16545

This commit is contained in:
Alexey Andreev
2017-03-01 20:04:50 +03:00
parent 8567db10b5
commit 723c9be5a0
6 changed files with 96 additions and 1 deletions
+6
View File
@@ -64,6 +64,12 @@ Kotlin.Long = function(low, high) {
this.high_ = high | 0; // force into 32 signed bits.
};
Kotlin.Long.$metadata$ = {
kind: "class",
simpleName: "Long",
interfaces:[]
};
// NOTE: Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the
// from* methods on which they depend.
+6 -1
View File
@@ -35,7 +35,12 @@ external fun <T : Any> jsClass(): JsClass<T>
@Deprecated("Use class literal and extension property `js` instead.", replaceWith = ReplaceWith("this::class.js"), level = DeprecationLevel.WARNING)
val <T : Any> T.jsClass: JsClass<T>
get() = js("Object").getPrototypeOf(this).constructor
get() = when (jsTypeOf(this)) {
"string" -> js("String")
"number" -> js("Number")
"boolean" -> js("Boolean")
else -> js("Object").getPrototypeOf(this).constructor
}
/**
* Obtains a constructor reference for the given `KClass`.