Skip to content

Commit 35ead98

Browse files
Kotlin: test invokedynamic when extraction
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b9116f3 commit 35ead98

3 files changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
test.kt:
2+
# 0| [CompilationUnit] test
3+
# 0| 1: [Class] TestKt
4+
# 3| 1: [Method] classify
5+
# 3| 3: [TypeAccess] int
6+
#-----| 4: (Parameters)
7+
# 3| 0: [Parameter] value
8+
# 3| 0: [TypeAccess] Object
9+
# 4| 5: [BlockStmt] { ... }
10+
# 8| 0: [ReturnStmt] return ...
11+
# 4| 0: [StmtExpr] <Stmt>
12+
# 4| 0: [BlockStmt] { ... }
13+
# 4| 0: [LocalVariableDeclStmt] var ...;
14+
# 4| 1: [LocalVariableDeclExpr] tmp0_subject
15+
# 4| 0: [VarAccess] value
16+
# 4| 1: [ExprStmt] <Expr>;
17+
# 4| 0: [WhenExpr] when ...
18+
# 5| 0: [WhenBranch] ... -> ...
19+
# 5| 0: [InstanceOfExpr] ...instanceof...
20+
# 5| 0: [VarAccess] tmp0_subject
21+
# 5| 1: [TypeAccess] String
22+
# 5| 1: [ExprStmt] <Expr>;
23+
# 5| 0: [MethodCall] length(...)
24+
# 5| -1: [ImplicitCastExpr] <implicit cast>
25+
# 5| 0: [TypeAccess] String
26+
# 5| 1: [VarAccess] value
27+
# 6| 1: [WhenBranch] ... -> ...
28+
# 6| 0: [InstanceOfExpr] ...instanceof...
29+
# 6| 0: [VarAccess] tmp0_subject
30+
# 6| 1: [TypeAccess] int
31+
# 6| 1: [ExprStmt] <Expr>;
32+
# 6| 0: [ImplicitCastExpr] <implicit cast>
33+
# 6| 0: [TypeAccess] int
34+
# 6| 1: [VarAccess] value
35+
# 7| 2: [WhenBranch] ... -> ...
36+
# 7| 0: [BooleanLiteral] true
37+
# 7| 1: [ExprStmt] <Expr>;
38+
# 7| 0: [IntegerLiteral] -1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle/code/java/PrintAst.ql
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// codeql-extractor-kotlin-options: -language-version 2.4 -jvm-target 21 -Xwhen-expressions=indy
2+
3+
fun classify(value: Any): Int =
4+
when (value) {
5+
is String -> value.length
6+
is Int -> value
7+
else -> -1
8+
}

0 commit comments

Comments
 (0)