Java to Kotlin converter: fixed bug with unnecessary "run { }" construct generated in loop body
This commit is contained in:
@@ -130,7 +130,7 @@ open class StatementVisitor(public val converter: Converter) : JavaElementVisito
|
||||
val updateConverted = converter.convertStatement(update)
|
||||
|
||||
val whileBody = if (updateConverted.isEmpty) {
|
||||
converter.convertStatement(body)
|
||||
convertStatementOrBlock(body)
|
||||
}
|
||||
else if (body is PsiBlockStatement) {
|
||||
val nameConflict = initialization is PsiDeclarationStatement && initialization.getDeclaredElements().any { loopVar ->
|
||||
|
||||
@@ -1177,6 +1177,11 @@ public class JavaToKotlinConverterTestGenerated extends AbstractJavaToKotlinConv
|
||||
doTest("j2k/tests/testData/ast/for/forWithReturn.java");
|
||||
}
|
||||
|
||||
@TestMetadata("infiniteFor.java")
|
||||
public void testInfiniteFor() throws Exception {
|
||||
doTest("j2k/tests/testData/ast/for/infiniteFor.java");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("j2k/tests/testData/ast/foreachStatement")
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
//method
|
||||
void foo() {
|
||||
for(;;) {
|
||||
if (!stop()) break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun foo() {
|
||||
while (true) {
|
||||
if (!stop()) break
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user