Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 73cd497

Browse files
tamasvajkigfoo
authored andcommitted
Add todo comment to move property from parameter initialization to constructor
1 parent 313912a commit 73cd497

5 files changed

Lines changed: 11 additions & 14 deletions

File tree

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,19 @@ open class KotlinFileExtractor(
371371
continue
372372
}
373373

374+
val expr = initializer.expression
375+
376+
if (expr is IrGetValue && expr.origin == IrStatementOrigin.INITIALIZE_PROPERTY_FROM_PARAMETER) {
377+
// TODO: this initialization should go into the default constructor
378+
continue
379+
}
380+
374381
val declLocId = tw.getLocation(decl)
375382
val stmtId = tw.getFreshIdLabel<DbExprstmt>()
376383
tw.writeStmts_exprstmt(stmtId, blockId, idx++, obinitId)
377384
tw.writeHasLocation(stmtId, declLocId)
378385
val assignmentId = tw.getFreshIdLabel<DbAssignexpr>()
379-
val type = useType(initializer.expression.type)
386+
val type = useType(expr.type)
380387
tw.writeExprs_assignexpr(assignmentId, type.javaResult.id, type.kotlinResult.id, stmtId, 0)
381388
tw.writeHasLocation(assignmentId, declLocId)
382389
tw.writeCallableEnclosingExpr(assignmentId, obinitId)
@@ -391,7 +398,7 @@ open class KotlinFileExtractor(
391398
val vId = useField(backingField)
392399
tw.writeVariableBinding(lhsId, vId)
393400

394-
extractExpressionExpr(initializer.expression, obinitId, assignmentId, 1, stmtId)
401+
extractExpressionExpr(expr, obinitId, assignmentId, 1, stmtId)
395402
}
396403
is IrAnonymousInitializer -> {
397404
if (decl.isStatic) {

java/ql/test/kotlin/library-tests/classes/initBlocks.expected

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ initCall
7070
| superChain.kt:2:1:2:60 | <obinit>(...) |
7171
| superChain.kt:3:1:3:60 | <obinit>(...) |
7272
initExpressions
73-
| classes.kt:4:17:4:28 | ...=... | 0 |
74-
| classes.kt:5:5:5:18 | ...=... | 1 |
73+
| classes.kt:5:5:5:18 | ...=... | 0 |
7574
| classes.kt:39:9:39:18 | f(...) | 0 |
7675
| classes.kt:42:5:42:18 | ...=... | 1 |
7776
| classes.kt:45:9:45:18 | f(...) | 2 |
78-
| classes.kt:53:18:53:29 | ...=... | 0 |
7977
| classes.kt:73:13:73:21 | ...=... | 0 |

java/ql/test/kotlin/library-tests/exprs/exprs.expected

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,6 @@
476476
| exprs.kt:139:13:139:16 | true | exprs.kt:138:1:140:1 | getClass | BooleanLiteral |
477477
| exprs.kt:139:13:139:23 | ::class | exprs.kt:138:1:140:1 | getClass | ClassExpr |
478478
| exprs.kt:142:1:144:1 | <obinit>(...) | exprs.kt:142:1:144:1 | C | MethodAccess |
479-
| exprs.kt:142:9:142:18 | ...=... | exprs.kt:142:1:144:1 | <obinit> | AssignExpr |
480-
| exprs.kt:142:9:142:18 | n | exprs.kt:142:1:144:1 | <obinit> | VarAccess |
481-
| exprs.kt:142:9:142:18 | n | exprs.kt:142:1:144:1 | <obinit> | VarAccess |
482479
| exprs.kt:142:9:142:18 | n | exprs.kt:142:9:142:18 | getN | VarAccess |
483480
| exprs.kt:143:27:143:31 | C | exprs.kt:143:5:143:33 | foo | TypeAccess |
484481
| exprs.kt:143:27:143:31 | new C(...) | exprs.kt:143:5:143:33 | foo | ClassInstanceExpr |
@@ -542,9 +539,6 @@
542539
| exprs.kt:172:1:176:1 | Color | exprs.kt:172:6:176:1 | Color | TypeAccess |
543540
| exprs.kt:172:1:176:1 | Unit | exprs.kt:172:6:176:1 | Color | TypeAccess |
544541
| exprs.kt:172:1:176:1 | new Enum(...) | exprs.kt:172:6:176:1 | Color | ClassInstanceExpr |
545-
| exprs.kt:172:18:172:29 | ...=... | exprs.kt:172:1:176:1 | <obinit> | AssignExpr |
546-
| exprs.kt:172:18:172:29 | rgb | exprs.kt:172:1:176:1 | <obinit> | VarAccess |
547-
| exprs.kt:172:18:172:29 | rgb | exprs.kt:172:1:176:1 | <obinit> | VarAccess |
548542
| exprs.kt:172:18:172:29 | rgb | exprs.kt:172:18:172:29 | getRgb | VarAccess |
549543
| exprs.kt:179:5:179:31 | south | exprs.kt:178:1:181:1 | enums | LocalVariableDeclExpr |
550544
| exprs.kt:179:27:179:31 | SOUTH | exprs.kt:178:1:181:1 | enums | VarAccess |

java/ql/test/kotlin/library-tests/variables/variableAccesses.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ varAcc
33
| variables.kt:3:5:3:21 | prop |
44
| variables.kt:10:1:10:21 | topLevel |
55
| variables.kt:16:11:16:18 | o |
6-
| variables.kt:16:11:16:18 | o |
7-
| variables.kt:16:11:16:18 | o |
86
instAcc
97
| variables.kt:21:9:21:9 | this |
108
| variables.kt:21:11:21:15 | this |

java/ql/test/kotlin/library-tests/variables/variables.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
| variables.kt:6:9:6:25 | int local | int | variables.kt:6:21:6:25 | ... + ... |
44
| variables.kt:10:1:10:21 | topLevel | int | file://:0:0:0:0 | <none> |
55
| variables.kt:16:11:16:18 | o | C1 | file://:0:0:0:0 | <none> |
6-
| variables.kt:16:11:16:18 | o | C1 | variables.kt:16:11:16:18 | o |
6+
| variables.kt:16:11:16:18 | o | C1 | file://:0:0:0:0 | <none> |
77
| variables.kt:23:9:23:10 | <this> | C1 | file://:0:0:0:0 | <none> |

0 commit comments

Comments
 (0)