Skip to content

Commit 18a5c48

Browse files
authored
Merge pull request #13508 from igfoo/igfoo/rc_kot
Kotlin: Backport some Kotlin 1.9 fixes to the rc/3.10 branch
2 parents a4ee152 + 293f903 commit 18a5c48

File tree

10 files changed

+5049
-6
lines changed

10 files changed

+5049
-6
lines changed

java/downgrades/ecfcf050952e54b1155fc89525db84af6ad34aaf/old.dbscheme

+1,256
Large diffs are not rendered by default.

java/downgrades/ecfcf050952e54b1155fc89525db84af6ad34aaf/semmlecode.dbscheme

+1,255
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
description: Remove ENUM_ENTRIES
2+
compatibility: full

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

+10-6
Original file line numberDiff line numberDiff line change
@@ -1701,12 +1701,13 @@ open class KotlinFileExtractor(
17011701

17021702
private fun extractSyntheticBody(b: IrSyntheticBody, callable: Label<out DbCallable>) {
17031703
with("synthetic body", b) {
1704-
when (b.kind) {
1705-
IrSyntheticBodyKind.ENUM_VALUES -> tw.writeKtSyntheticBody(callable, 1)
1706-
IrSyntheticBodyKind.ENUM_VALUEOF -> tw.writeKtSyntheticBody(callable, 2)
1704+
val kind = b.kind
1705+
when {
1706+
kind == IrSyntheticBodyKind.ENUM_VALUES -> tw.writeKtSyntheticBody(callable, 1)
1707+
kind == IrSyntheticBodyKind.ENUM_VALUEOF -> tw.writeKtSyntheticBody(callable, 2)
1708+
kind == kind_ENUM_ENTRIES -> tw.writeKtSyntheticBody(callable, 3)
17071709
else -> {
1708-
// TODO: Support IrSyntheticBodyKind.ENUM_ENTRIES
1709-
logger.errorElement("Unhandled synthetic body kind " + b.kind.javaClass, b)
1710+
logger.errorElement("Unhandled synthetic body kind " + kind, b)
17101711
}
17111712
}
17121713
}
@@ -5316,7 +5317,10 @@ open class KotlinFileExtractor(
53165317
private fun extractTypeAccessRecursive(t: IrType, location: Label<out DbLocation>, parent: Label<out DbExprparent>, idx: Int, typeContext: TypeContext = TypeContext.OTHER): Label<out DbExpr> {
53175318
val typeAccessId = extractTypeAccess(useType(t, typeContext), location, parent, idx)
53185319
if (t is IrSimpleType) {
5319-
t.arguments.forEachIndexed { argIdx, arg ->
5320+
// From 1.9, the list might change when we call erase,
5321+
// so we make a copy that it is safe to iterate over.
5322+
val argumentsCopy = t.arguments.toList()
5323+
argumentsCopy.forEachIndexed { argIdx, arg ->
53205324
extractWildcardTypeAccessRecursive(arg, location, typeAccessId, argIdx)
53215325
}
53225326
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind
4+
5+
val kind_ENUM_ENTRIES: IrSyntheticBodyKind? = null
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind
4+
5+
val kind_ENUM_ENTRIES: IrSyntheticBodyKind? = IrSyntheticBodyKind.ENUM_ENTRIES
6+

java/ql/lib/config/semmlecode.dbscheme

+1
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,7 @@ ktSyntheticBody(
12191219
int kind: int ref
12201220
// 1: ENUM_VALUES
12211221
// 2: ENUM_VALUEOF
1222+
// 3: ENUM_ENTRIES
12221223
)
12231224

12241225
ktLocalFunction(

0 commit comments

Comments
 (0)