JS: Fix TranslationRuntimeException on 'for (x in ("a"))' #KT-22376 Fixed
This commit is contained in:
committed by
Anton Bannykh
parent
db3c9962a2
commit
65ba57bcae
@@ -99,7 +99,10 @@ private val indicesFqName = FqName("kotlin.collections.indices")
|
|||||||
private val sequenceFqName = FqName("kotlin.sequences.Sequence")
|
private val sequenceFqName = FqName("kotlin.sequences.Sequence")
|
||||||
|
|
||||||
fun translateForExpression(expression: KtForExpression, context: TranslationContext): JsStatement {
|
fun translateForExpression(expression: KtForExpression, context: TranslationContext): JsStatement {
|
||||||
val loopRange = KtPsiUtil.deparenthesize(getLoopRange(expression))!!
|
val loopRange = getLoopRange(expression).let {
|
||||||
|
val deparenthesized = KtPsiUtil.deparenthesize(it)!!
|
||||||
|
if (deparenthesized is KtStringTemplateExpression) it else deparenthesized
|
||||||
|
}
|
||||||
val rangeType = getTypeForExpression(context.bindingContext(), loopRange)
|
val rangeType = getTypeForExpression(context.bindingContext(), loopRange)
|
||||||
|
|
||||||
fun isForOverRange(): Boolean {
|
fun isForOverRange(): Boolean {
|
||||||
|
|||||||
@@ -47,6 +47,19 @@ fun box(): String {
|
|||||||
sLong += i
|
sLong += i
|
||||||
assertEquals(55L, sLong)
|
assertEquals(55L, sLong)
|
||||||
|
|
||||||
|
// KT-22376
|
||||||
|
global = ""
|
||||||
|
for (s in "AB")
|
||||||
|
global += s
|
||||||
|
assertEquals("AB", global)
|
||||||
|
|
||||||
|
for (s in (("CD")))
|
||||||
|
global += s
|
||||||
|
assertEquals("ABCD", global)
|
||||||
|
|
||||||
|
for (s in (("EF")))
|
||||||
|
global += s
|
||||||
|
assertEquals("ABCDEF", global)
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user