JS/RTTI: removed Kotlin.orNull(Kotlin.isAny) optimization
This commit is contained in:
committed by
Alexey Andreev
parent
f7af868d4f
commit
fcd941ad49
-2
@@ -36,8 +36,6 @@ var JsFunction.isLocal: Boolean by MetadataProperty(default = false)
|
|||||||
|
|
||||||
var JsParameter.hasDefaultValue: Boolean by MetadataProperty(default = false)
|
var JsParameter.hasDefaultValue: Boolean by MetadataProperty(default = false)
|
||||||
|
|
||||||
var JsConditional.isCastExpression: Boolean by MetadataProperty(default = false)
|
|
||||||
|
|
||||||
var JsInvocation.typeCheck: TypeCheck? by MetadataProperty(default = null)
|
var JsInvocation.typeCheck: TypeCheck? by MetadataProperty(default = null)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-3
@@ -87,9 +87,7 @@ public final class PatternTranslator extends AbstractTranslator {
|
|||||||
onFail = new JsInvocation(throwCCEFunRef);
|
onFail = new JsInvocation(throwCCEFunRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
JsConditional conditional = new JsConditional(isCheck, temporary.reference(), onFail);
|
return new JsConditional(isCheck, temporary.reference(), onFail);
|
||||||
MetadataProperties.setCastExpression(conditional, true);
|
|
||||||
return conditional;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.js.translate.utils
|
|||||||
|
|
||||||
import com.google.dart.compiler.backend.js.ast.*
|
import com.google.dart.compiler.backend.js.ast.*
|
||||||
import com.google.dart.compiler.backend.js.ast.metadata.TypeCheck
|
import com.google.dart.compiler.backend.js.ast.metadata.TypeCheck
|
||||||
import com.google.dart.compiler.backend.js.ast.metadata.isCastExpression
|
|
||||||
import com.google.dart.compiler.backend.js.ast.metadata.typeCheck
|
import com.google.dart.compiler.backend.js.ast.metadata.typeCheck
|
||||||
import org.jetbrains.kotlin.js.inline.util.IdentitySet
|
import org.jetbrains.kotlin.js.inline.util.IdentitySet
|
||||||
import org.jetbrains.kotlin.js.translate.context.TranslationContext
|
import org.jetbrains.kotlin.js.translate.context.TranslationContext
|
||||||
@@ -54,12 +53,6 @@ private class TypeCheckRewritingVisitor(private val context: TranslationContext)
|
|||||||
override fun endVisit(x: JsConditional, ctx: JsContext<JsNode>) {
|
override fun endVisit(x: JsConditional, ctx: JsContext<JsNode>) {
|
||||||
val test = x.testExpression
|
val test = x.testExpression
|
||||||
|
|
||||||
if (x.isCastExpression &&
|
|
||||||
test is JsBinaryOperation &&
|
|
||||||
test.operator == JsBinaryOperator.ASG
|
|
||||||
) {
|
|
||||||
ctx.replaceMe(test.arg2)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visit(x: JsInvocation, ctx: JsContext<JsNode>): Boolean {
|
override fun visit(x: JsInvocation, ctx: JsContext<JsNode>): Boolean {
|
||||||
@@ -102,10 +95,8 @@ private class TypeCheckRewritingVisitor(private val context: TranslationContext)
|
|||||||
|
|
||||||
// `Kotlin.orNull(calleeArgument)(argument)` -> `(tmp = argument) == null || calleeArgument(tmp)`
|
// `Kotlin.orNull(calleeArgument)(argument)` -> `(tmp = argument) == null || calleeArgument(tmp)`
|
||||||
if (callee.typeCheck == TypeCheck.OR_NULL) {
|
if (callee.typeCheck == TypeCheck.OR_NULL) {
|
||||||
if (calleeArgument is JsInvocation) {
|
if (calleeArgument is JsInvocation && calleeArgument.typeCheck == TypeCheck.OR_NULL) {
|
||||||
if (calleeArgument.typeCheck == TypeCheck.OR_NULL) return JsInvocation(calleeArgument, argument)
|
return JsInvocation(calleeArgument, argument)
|
||||||
|
|
||||||
if (calleeArgument.typeCheck == TypeCheck.IS_ANY) return argument
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var nullCheckTarget = argument
|
var nullCheckTarget = argument
|
||||||
|
|||||||
Reference in New Issue
Block a user