JS/RTTI. Fix runtime checking against kotlin.CharSequence
This commit is contained in:
+1
-1
@@ -20,7 +20,7 @@ import com.google.common.base.Predicate
|
|||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|
||||||
interface TypePredicate : Predicate<KotlinType> {
|
public interface TypePredicate : Predicate<KotlinType> {
|
||||||
override fun apply(type: KotlinType?): Boolean
|
override fun apply(type: KotlinType?): Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ public final class Namer {
|
|||||||
public static final String PRIMITIVE_COMPARE_TO = "primitiveCompareTo";
|
public static final String PRIMITIVE_COMPARE_TO = "primitiveCompareTo";
|
||||||
public static final String IS_CHAR = "isChar";
|
public static final String IS_CHAR = "isChar";
|
||||||
public static final String IS_NUMBER = "isNumber";
|
public static final String IS_NUMBER = "isNumber";
|
||||||
|
public static final String IS_CHAR_SEQUENCE = "isCharSequence";
|
||||||
|
|
||||||
public static final String CALLEE_NAME = "$fun";
|
public static final String CALLEE_NAME = "$fun";
|
||||||
|
|
||||||
@@ -412,6 +413,11 @@ public final class Namer {
|
|||||||
return kotlin("isComparable");
|
return kotlin("isComparable");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public JsExpression isCharSequence() {
|
||||||
|
return kotlin(IS_CHAR_SEQUENCE);
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private JsExpression invokeFunctionAndSetTypeCheckMetadata(
|
private JsExpression invokeFunctionAndSetTypeCheckMetadata(
|
||||||
@NotNull String functionName,
|
@NotNull String functionName,
|
||||||
|
|||||||
+2
@@ -163,6 +163,8 @@ public final class PatternTranslator extends AbstractTranslator {
|
|||||||
|
|
||||||
if (isArray(type)) return Namer.IS_ARRAY_FUN_REF;
|
if (isArray(type)) return Namer.IS_ARRAY_FUN_REF;
|
||||||
|
|
||||||
|
if (TypePredicatesKt.getCHAR_SEQUENCE().apply(type)) return namer().isCharSequence();
|
||||||
|
|
||||||
if (TypePredicatesKt.getCOMPARABLE().apply(type)) return namer().isComparable();
|
if (TypePredicatesKt.getCOMPARABLE().apply(type)) return namer().isComparable();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
+7
-1
@@ -17,6 +17,8 @@
|
|||||||
(function (Kotlin) {
|
(function (Kotlin) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
Kotlin.CharSequence = Kotlin.createTraitNow(null);
|
||||||
|
|
||||||
// Shims for String
|
// Shims for String
|
||||||
if (typeof String.prototype.startsWith === "undefined") {
|
if (typeof String.prototype.startsWith === "undefined") {
|
||||||
String.prototype.startsWith = function(searchString, position) {
|
String.prototype.startsWith = function(searchString, position) {
|
||||||
@@ -135,6 +137,10 @@
|
|||||||
Kotlin.isType(value, Kotlin.Comparable);
|
Kotlin.isType(value, Kotlin.Comparable);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Kotlin.isCharSequence = function (value) {
|
||||||
|
return typeof value === "string" || Kotlin.isType(value, Kotlin.CharSequence);
|
||||||
|
};
|
||||||
|
|
||||||
Kotlin.charInc = function (value) {
|
Kotlin.charInc = function (value) {
|
||||||
return String.fromCharCode(value.charCodeAt(0)+1);
|
return String.fromCharCode(value.charCodeAt(0)+1);
|
||||||
};
|
};
|
||||||
@@ -1140,7 +1146,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Kotlin.StringBuilder = Kotlin.createClassNow(null,
|
Kotlin.StringBuilder = Kotlin.createClassNow([Kotlin.CharSequence],
|
||||||
function (content) {
|
function (content) {
|
||||||
this.string = typeof(content) == "string" ? content : "";
|
this.string = typeof(content) == "string" ? content : "";
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
Reference in New Issue
Block a user