Remove unnecessary code in PatternTranslator.
Adapted from https://github.com/develar/kotlin/commit/a9e0a42fb1347fa8e21c86b5a073ef8a7c873da0.
This commit is contained in:
+5
-14
@@ -16,7 +16,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.k2js.translate.expression;
|
package org.jetbrains.k2js.translate.expression;
|
||||||
|
|
||||||
import com.google.dart.compiler.backend.js.ast.*;
|
import com.google.dart.compiler.backend.js.ast.JsExpression;
|
||||||
|
import com.google.dart.compiler.backend.js.ast.JsInvocation;
|
||||||
|
import com.google.dart.compiler.backend.js.ast.JsName;
|
||||||
|
import com.google.dart.compiler.backend.js.ast.JsNameRef;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
@@ -131,19 +134,7 @@ public final class PatternTranslator extends AbstractTranslator {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private JsExpression translateExpressionPattern(@NotNull JsExpression expressionToMatch, JetExpressionPattern pattern) {
|
private JsExpression translateExpressionPattern(@NotNull JsExpression expressionToMatch, JetExpressionPattern pattern) {
|
||||||
JsExpression expressionToMatchAgainst = translateExpressionForExpressionPattern(pattern);
|
JsExpression expressionToMatchAgainst = translateExpressionForExpressionPattern(pattern);
|
||||||
JsBinaryOperation eq = equality(expressionToMatch, expressionToMatchAgainst);
|
return equality(expressionToMatch, expressionToMatchAgainst);
|
||||||
// Uncaught TypeError: Cannot convert object to primitive value
|
|
||||||
if (context().isEcma5()) {
|
|
||||||
if (expressionToMatchAgainst instanceof JsNumberLiteral ||
|
|
||||||
expressionToMatchAgainst instanceof JsStringLiteral ||
|
|
||||||
expressionToMatchAgainst instanceof JsLiteral.JsBooleanLiteral) {
|
|
||||||
JsNameRef valueOf = new JsNameRef("valueOf");
|
|
||||||
valueOf.setQualifier(expressionToMatch);
|
|
||||||
return and(valueOf, eq);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return eq;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user