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")
|
||||
|
||||
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)
|
||||
|
||||
fun isForOverRange(): Boolean {
|
||||
|
||||
@@ -47,6 +47,19 @@ fun box(): String {
|
||||
sLong += i
|
||||
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"
|
||||
}
|
||||
Reference in New Issue
Block a user