Kotlin: Fix array set operator extraction

This commit is contained in:
Tamas Vajk
2022-09-05 10:19:35 +02:00
parent 608f99bd0d
commit 6f7f760682
3 changed files with 13 additions and 3 deletions

View File

@@ -2208,7 +2208,7 @@ open class KotlinFileExtractor(
tw.writeExprsKotlinType(id, type.kotlinResult.id)
binopDisp(id)
}
isFunction(target, "kotlin", "(some array type)", { isArrayType(it) }, "set") && c.origin == IrStatementOrigin.EQ -> {
isFunction(target, "kotlin", "(some array type)", { isArrayType(it) }, "set") && c.origin == IrStatementOrigin.EQ && c.dispatchReceiver != null -> {
val array = c.dispatchReceiver
val arrayIdx = c.getValueArgument(0)
val assignedValue = c.getValueArgument(1)

View File

@@ -33,9 +33,21 @@ test.kt:
# 6| 3: [ExprStmt] <Expr>;
# 6| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 6| 0: [TypeAccess] Unit
# 6| 1: [MethodAccess] set(...)
# 6| -1: [TypeAccess] TestKt
# 6| 0: [VarAccess] arr
# 6| 1: [IntegerLiteral] 1
# 6| 2: [IntegerLiteral] 2
# 6| 3: [IntegerLiteral] 3
# 7| 4: [ExprStmt] <Expr>;
# 7| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 7| 0: [TypeAccess] Unit
# 7| 1: [MethodAccess] set(...)
# 7| -1: [TypeAccess] TestKt
# 7| 0: [VarAccess] arr
# 7| 1: [IntegerLiteral] 1
# 7| 2: [ClassInstanceExpr] new C(...)
# 7| -3: [TypeAccess] C
# 10| 2: [ExtensionMethod] get
# 10| 3: [TypeAccess] String
#-----| 4: (Parameters)

View File

@@ -1,2 +0,0 @@
| test.kt:6:5:6:13 | Unexpected Array.set function signature |
| test.kt:7:5:7:10 | Unexpected Array.set function signature |