Add todo comment to move property from parameter initialization to constructor

This commit is contained in:
Tamas Vajk
2021-12-20 09:23:25 +01:00
committed by Ian Lynagh
parent 313912a131
commit 73cd497427
5 changed files with 11 additions and 14 deletions

View File

@@ -371,12 +371,19 @@ open class KotlinFileExtractor(
continue
}
val expr = initializer.expression
if (expr is IrGetValue && expr.origin == IrStatementOrigin.INITIALIZE_PROPERTY_FROM_PARAMETER) {
// TODO: this initialization should go into the default constructor
continue
}
val declLocId = tw.getLocation(decl)
val stmtId = tw.getFreshIdLabel<DbExprstmt>()
tw.writeStmts_exprstmt(stmtId, blockId, idx++, obinitId)
tw.writeHasLocation(stmtId, declLocId)
val assignmentId = tw.getFreshIdLabel<DbAssignexpr>()
val type = useType(initializer.expression.type)
val type = useType(expr.type)
tw.writeExprs_assignexpr(assignmentId, type.javaResult.id, type.kotlinResult.id, stmtId, 0)
tw.writeHasLocation(assignmentId, declLocId)
tw.writeCallableEnclosingExpr(assignmentId, obinitId)
@@ -391,7 +398,7 @@ open class KotlinFileExtractor(
val vId = useField(backingField)
tw.writeVariableBinding(lhsId, vId)
extractExpressionExpr(initializer.expression, obinitId, assignmentId, 1, stmtId)
extractExpressionExpr(expr, obinitId, assignmentId, 1, stmtId)
}
is IrAnonymousInitializer -> {
if (decl.isStatic) {

View File

@@ -70,10 +70,8 @@ initCall
| superChain.kt:2:1:2:60 | <obinit>(...) |
| superChain.kt:3:1:3:60 | <obinit>(...) |
initExpressions
| classes.kt:4:17:4:28 | ...=... | 0 |
| classes.kt:5:5:5:18 | ...=... | 1 |
| classes.kt:5:5:5:18 | ...=... | 0 |
| classes.kt:39:9:39:18 | f(...) | 0 |
| classes.kt:42:5:42:18 | ...=... | 1 |
| classes.kt:45:9:45:18 | f(...) | 2 |
| classes.kt:53:18:53:29 | ...=... | 0 |
| classes.kt:73:13:73:21 | ...=... | 0 |

View File

@@ -476,9 +476,6 @@
| exprs.kt:139:13:139:16 | true | exprs.kt:138:1:140:1 | getClass | BooleanLiteral |
| exprs.kt:139:13:139:23 | ::class | exprs.kt:138:1:140:1 | getClass | ClassExpr |
| exprs.kt:142:1:144:1 | <obinit>(...) | exprs.kt:142:1:144:1 | C | MethodAccess |
| exprs.kt:142:9:142:18 | ...=... | exprs.kt:142:1:144:1 | <obinit> | AssignExpr |
| exprs.kt:142:9:142:18 | n | exprs.kt:142:1:144:1 | <obinit> | VarAccess |
| exprs.kt:142:9:142:18 | n | exprs.kt:142:1:144:1 | <obinit> | VarAccess |
| exprs.kt:142:9:142:18 | n | exprs.kt:142:9:142:18 | getN | VarAccess |
| exprs.kt:143:27:143:31 | C | exprs.kt:143:5:143:33 | foo | TypeAccess |
| exprs.kt:143:27:143:31 | new C(...) | exprs.kt:143:5:143:33 | foo | ClassInstanceExpr |
@@ -542,9 +539,6 @@
| exprs.kt:172:1:176:1 | Color | exprs.kt:172:6:176:1 | Color | TypeAccess |
| exprs.kt:172:1:176:1 | Unit | exprs.kt:172:6:176:1 | Color | TypeAccess |
| exprs.kt:172:1:176:1 | new Enum(...) | exprs.kt:172:6:176:1 | Color | ClassInstanceExpr |
| exprs.kt:172:18:172:29 | ...=... | exprs.kt:172:1:176:1 | <obinit> | AssignExpr |
| exprs.kt:172:18:172:29 | rgb | exprs.kt:172:1:176:1 | <obinit> | VarAccess |
| exprs.kt:172:18:172:29 | rgb | exprs.kt:172:1:176:1 | <obinit> | VarAccess |
| exprs.kt:172:18:172:29 | rgb | exprs.kt:172:18:172:29 | getRgb | VarAccess |
| exprs.kt:179:5:179:31 | south | exprs.kt:178:1:181:1 | enums | LocalVariableDeclExpr |
| exprs.kt:179:27:179:31 | SOUTH | exprs.kt:178:1:181:1 | enums | VarAccess |

View File

@@ -3,8 +3,6 @@ varAcc
| variables.kt:3:5:3:21 | prop |
| variables.kt:10:1:10:21 | topLevel |
| variables.kt:16:11:16:18 | o |
| variables.kt:16:11:16:18 | o |
| variables.kt:16:11:16:18 | o |
instAcc
| variables.kt:21:9:21:9 | this |
| variables.kt:21:11:21:15 | this |

View File

@@ -3,5 +3,5 @@
| variables.kt:6:9:6:25 | int local | int | variables.kt:6:21:6:25 | ... + ... |
| variables.kt:10:1:10:21 | topLevel | int | file://:0:0:0:0 | <none> |
| variables.kt:16:11:16:18 | o | C1 | file://:0:0:0:0 | <none> |
| variables.kt:16:11:16:18 | o | C1 | variables.kt:16:11:16:18 | o |
| variables.kt:16:11:16:18 | o | C1 | file://:0:0:0:0 | <none> |
| variables.kt:23:9:23:10 | <this> | C1 | file://:0:0:0:0 | <none> |