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

Skip to content

Commit 6c95728

Browse files
committed
Kotlin: Add support for enum value accesses
1 parent d565a16 commit 6c95728

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,17 @@ class X {
15201520
tw.writeVariableBinding(id, vId)
15211521
}
15221522
}
1523+
is IrGetEnumValue -> {
1524+
val exprParent = parent.expr(e, callable)
1525+
val id = tw.getFreshIdLabel<DbVaraccess>()
1526+
val type = useType(e.type)
1527+
val locId = tw.getLocation(e)
1528+
tw.writeExprs_varaccess(id, type.javaResult.id, type.kotlinResult.id, exprParent.parent, exprParent.idx)
1529+
tw.writeHasLocation(id, locId)
1530+
val owner = e.symbol.owner
1531+
val vId = useEnumEntry(owner)
1532+
tw.writeVariableBinding(id, vId)
1533+
}
15231534
is IrSetValue -> {
15241535
val exprParent = parent.expr(e, callable)
15251536
val id = tw.getFreshIdLabel<DbAssignexpr>()

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@
168168
| exprs.kt:92:18:92:29 | rgb | VarAccess |
169169
| exprs.kt:92:18:92:29 | rgb | VarAccess |
170170
| exprs.kt:99:5:99:31 | south | LocalVariableDeclExpr |
171+
| exprs.kt:99:27:99:31 | SOUTH | VarAccess |
171172
| exprs.kt:100:5:100:27 | green | LocalVariableDeclExpr |
173+
| exprs.kt:100:23:100:27 | GREEN | VarAccess |
172174
| file://:0:0:0:0 | Color | TypeAccess |
173175
| file://:0:0:0:0 | Direction | TypeAccess |
174176
| file://:0:0:0:0 | q | VarAccess |

0 commit comments

Comments
 (0)