JS backend: report expression location on error in StringTemplateTranslator.
(cherry picked from commit a2765d3)
This commit is contained in:
+2
-4
@@ -34,10 +34,10 @@ import org.jetbrains.k2js.translate.intrinsic.functions.patterns.NamePredicate;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.jetbrains.k2js.translate.utils.ErrorReportingUtils.message;
|
||||
import static org.jetbrains.k2js.translate.utils.JsAstUtils.sum;
|
||||
import static org.jetbrains.k2js.translate.utils.JsDescriptorUtils.getNameIfStandardType;
|
||||
|
||||
|
||||
public final class StringTemplateTranslator extends AbstractTranslator {
|
||||
private final JetStringTemplateEntry[] expressionEntries;
|
||||
|
||||
@@ -47,14 +47,12 @@ public final class StringTemplateTranslator extends AbstractTranslator {
|
||||
return (new StringTemplateTranslator(expression, context).translate());
|
||||
}
|
||||
|
||||
|
||||
|
||||
private StringTemplateTranslator(@NotNull JetStringTemplateExpression expression,
|
||||
@NotNull TranslationContext context) {
|
||||
super(context);
|
||||
|
||||
expressionEntries = expression.getEntries();
|
||||
assert expressionEntries.length != 0 : "String template must have one or more entries.";
|
||||
assert expressionEntries.length != 0 : message(expression, "String template must have one or more entries.");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package foo
|
||||
|
||||
// test String template must have one or more entries.
|
||||
public class Fe {
|
||||
fun open(method:String, url: String, async: Boolean = true, user: String = "", password: String = "") = "$method $url $async $user $password"
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
val a = "abc"
|
||||
val b = "def"
|
||||
@@ -10,5 +15,5 @@ fun box(): Boolean {
|
||||
val v1 = null
|
||||
if ("returns null null" != "returns $v1 ${null}") return false
|
||||
|
||||
return true
|
||||
return Fe().open("22", "33") == "22 33 true "
|
||||
}
|
||||
Reference in New Issue
Block a user