Skip to content

Commit 6f7f760

Browse files
committed
Kotlin: Fix array set operator extraction
1 parent 608f99b commit 6f7f760

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2208,7 +2208,7 @@ open class KotlinFileExtractor(
22082208
tw.writeExprsKotlinType(id, type.kotlinResult.id)
22092209
binopDisp(id)
22102210
}
2211-
isFunction(target, "kotlin", "(some array type)", { isArrayType(it) }, "set") && c.origin == IrStatementOrigin.EQ -> {
2211+
isFunction(target, "kotlin", "(some array type)", { isArrayType(it) }, "set") && c.origin == IrStatementOrigin.EQ && c.dispatchReceiver != null -> {
22122212
val array = c.dispatchReceiver
22132213
val arrayIdx = c.getValueArgument(0)
22142214
val assignedValue = c.getValueArgument(1)

java/ql/test/kotlin/library-tests/operator-overloads/PrintAst.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,21 @@ test.kt:
3333
# 6| 3: [ExprStmt] <Expr>;
3434
# 6| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
3535
# 6| 0: [TypeAccess] Unit
36+
# 6| 1: [MethodAccess] set(...)
37+
# 6| -1: [TypeAccess] TestKt
38+
# 6| 0: [VarAccess] arr
39+
# 6| 1: [IntegerLiteral] 1
40+
# 6| 2: [IntegerLiteral] 2
41+
# 6| 3: [IntegerLiteral] 3
3642
# 7| 4: [ExprStmt] <Expr>;
3743
# 7| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
3844
# 7| 0: [TypeAccess] Unit
45+
# 7| 1: [MethodAccess] set(...)
46+
# 7| -1: [TypeAccess] TestKt
47+
# 7| 0: [VarAccess] arr
48+
# 7| 1: [IntegerLiteral] 1
49+
# 7| 2: [ClassInstanceExpr] new C(...)
50+
# 7| -3: [TypeAccess] C
3951
# 10| 2: [ExtensionMethod] get
4052
# 10| 3: [TypeAccess] String
4153
#-----| 4: (Parameters)
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
| test.kt:6:5:6:13 | Unexpected Array.set function signature |
2-
| test.kt:7:5:7:10 | Unexpected Array.set function signature |

0 commit comments

Comments
 (0)