Skip to content

Commit 4cd0f1c

Browse files
committed
Apply code review findings
1 parent d745381 commit 4cd0f1c

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3191,9 +3191,7 @@ open class KotlinFileExtractor(
31913191
*/
31923192

31933193
if (e.origin != IrStatementOrigin.FOR_LOOP ||
3194-
e.statements.size != 2 ||
3195-
(e.statements[0] as? IrVariable)?.origin != IrDeclarationOrigin.FOR_LOOP_ITERATOR ||
3196-
(e.statements[1] as? IrWhileLoop)?.origin != IrStatementOrigin.FOR_LOOP_INNER_WHILE) {
3194+
e.statements.size != 2) {
31973195
return false
31983196
}
31993197

@@ -3240,9 +3238,9 @@ open class KotlinFileExtractor(
32403238
}
32413239

32423240
val id = extractLoop(innerWhile, null, parent, callable) { p, idx ->
3243-
val loopId = tw.getFreshIdLabel<DbEnhancedforstmt>()
3244-
tw.writeStmts_enhancedforstmt(loopId, p, idx, callable)
3245-
loopId
3241+
tw.getFreshIdLabel<DbEnhancedforstmt>().also {
3242+
tw.writeStmts_enhancedforstmt(it, p, idx, callable)
3243+
}
32463244
}
32473245

32483246
extractVariableExpr(loopVar, callable, id, 0, id, extractInitializer = false)
@@ -4143,13 +4141,13 @@ open class KotlinFileExtractor(
41434141
) {
41444142
val id = extractLoop(loop, 1, stmtExprParent, callable) { parent, idx ->
41454143
if (loop is IrWhileLoop) {
4146-
val id = tw.getFreshIdLabel<DbWhilestmt>()
4147-
tw.writeStmts_whilestmt(id, parent, idx, callable)
4148-
id
4144+
tw.getFreshIdLabel<DbWhilestmt>().also {
4145+
tw.writeStmts_whilestmt(it, parent, idx, callable)
4146+
}
41494147
} else {
4150-
val id = tw.getFreshIdLabel<DbDostmt>()
4151-
tw.writeStmts_dostmt(id, parent, idx, callable)
4152-
id
4148+
tw.getFreshIdLabel<DbDostmt>().also {
4149+
tw.writeStmts_dostmt(it, parent, idx, callable)
4150+
}
41534151
}
41544152
}
41554153
extractExpressionExpr(loop.condition, callable, id, 0, id)

0 commit comments

Comments
 (0)