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

Skip to content

Commit 854a03d

Browse files
committed
Kotlin: Fix property initialisers
1 parent aefe5c5 commit 854a03d

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,15 +1228,12 @@ open class KotlinFileExtractor(
12281228
tw.writeExprs_assignexpr(assignmentId, type.javaResult.id, type.kotlinResult.id, stmtId, 0)
12291229
tw.writeHasLocation(assignmentId, declLocId)
12301230

1231-
/*
1232-
TODO
12331231
val lhsId = tw.getFreshIdLabel<DbVaraccess>()
12341232
val lhsType = useType(backingField.type)
12351233
tw.writeExprs_varaccess(lhsId, lhsType.javaResult.id, lhsType.kotlinResult.id, assignmentId, 0)
12361234
tw.writeHasLocation(lhsId, declLocId)
1237-
val vId = useProperty(decl) // todo: fix this. We should be assigning the field, and not the property
1235+
val vId = useField(backingField)
12381236
tw.writeVariableBinding(lhsId, vId)
1239-
*/
12401237

12411238
extractExpressionExpr(initializer.expression, obinitId, assignmentId, 1)
12421239
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
| exprs.kt:64:1:66:1 | <obinit>(...) | MethodAccess |
113113
| exprs.kt:64:9:64:18 | ...=... | AssignExpr |
114114
| exprs.kt:64:9:64:18 | n | VarAccess |
115+
| exprs.kt:64:9:64:18 | n | VarAccess |
115116
| exprs.kt:65:27:65:31 | new C(...) | ClassInstanceExpr |
116117
| exprs.kt:65:29:65:30 | 42 | IntegerLiteral |
117118
| exprs.kt:68:1:68:18 | <obinit>(...) | MethodAccess |
@@ -165,6 +166,7 @@
165166
| exprs.kt:92:1:96:1 | new Enum(...) | ClassInstanceExpr |
166167
| exprs.kt:92:18:92:29 | ...=... | AssignExpr |
167168
| exprs.kt:92:18:92:29 | rgb | VarAccess |
169+
| exprs.kt:92:18:92:29 | rgb | VarAccess |
168170
| exprs.kt:99:5:99:31 | south | LocalVariableDeclExpr |
169171
| exprs.kt:99:27:99:31 | SOUTH | VarAccess |
170172
| exprs.kt:100:5:100:27 | green | LocalVariableDeclExpr |

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
varAcc
2+
| variables.kt:3:5:3:21 | prop |
3+
| variables.kt:16:11:16:18 | o |
24
| variables.kt:16:11:16:18 | o |
35
instAcc
46
| variables.kt:21:11:21:15 | this |
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
| variables.kt:2:1:8:1 | other | file://:0:0:0:0 | Object | file://:0:0:0:0 | <none> |
2-
| variables.kt:3:5:3:21 | prop | file://:0:0:0:0 | int | file://:0:0:0:0 | <none> |
2+
| variables.kt:3:5:3:21 | prop | file://:0:0:0:0 | int | variables.kt:3:21:3:21 | 1 |
33
| variables.kt:5:20:5:29 | param | file://:0:0:0:0 | int | file://:0:0:0:0 | <none> |
44
| variables.kt:6:9:6:25 | int local | file://:0:0:0:0 | int | variables.kt:6:21:6:25 | ... + ... |
55
| variables.kt:10:1:10:21 | topLevel | file://:0:0:0:0 | int | file://:0:0:0:0 | <none> |
66
| variables.kt:12:1:15:1 | other | file://:0:0:0:0 | Object | file://:0:0:0:0 | <none> |
77
| variables.kt:16:1:34:1 | other | file://:0:0:0:0 | Object | file://:0:0:0:0 | <none> |
88
| variables.kt:16:11:16:18 | o | variables.kt:12:1:15:1 | C1 | file://:0:0:0:0 | <none> |
9-
| variables.kt:16:11:16:18 | o | variables.kt:12:1:15:1 | C1 | file://:0:0:0:0 | <none> |
9+
| variables.kt:16:11:16:18 | o | variables.kt:12:1:15:1 | C1 | variables.kt:16:11:16:18 | o |
1010
| variables.kt:36:1:45:1 | other | file://:0:0:0:0 | Object | file://:0:0:0:0 | <none> |
1111
| variables.kt:38:11:44:5 | other | file://:0:0:0:0 | Object | file://:0:0:0:0 | <none> |

0 commit comments

Comments
 (0)