Skip to content

Commit 5019dde

Browse files
committed
Kotlin: Inline cast
1 parent f296f8d commit 5019dde

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2975,10 +2975,11 @@ open class KotlinFileExtractor(
29752975
val locId = tw.getLocation(s)
29762976
tw.writeStmts_block(blockId, parent, idx, callable)
29772977
tw.writeHasLocation(blockId, locId)
2978-
// For Kotlin < 2.3, s.delegate is not-nullable. Cast to be nullable,
2979-
// as a workaround to silence warnings for kotlin < 2.3 about the elvis
2980-
// operator being redundant.
2981-
val delegate: IrVariable? = cast(s.delegate)
2978+
// For Kotlin < 2.3, s.delegate is not-nullable, but for Kotlin >= 2.3
2979+
// it is nullable. Cast to nullable to handle both cases uniformly.
2980+
// For Kotlin >= 2.3, the cast is redundant, hence the suppress.
2981+
@Suppress("USELESS_CAST")
2982+
val delegate: IrVariable? = s.delegate as IrVariable?
29822983
val propId = tw.getFreshIdLabel<DbKt_property>()
29832984

29842985
if (delegate == null) {

java/kotlin-extractor/src/main/kotlin/utils/Helpers.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,3 @@ fun IrFunction.isLocalFunction(): Boolean {
1111

1212
val IrClass.isInterfaceLike
1313
get() = kind == ClassKind.INTERFACE || kind == ClassKind.ANNOTATION_CLASS
14-
15-
@Suppress("UNCHECKED_CAST")
16-
fun <T> cast(value: Any?): T = value as T

0 commit comments

Comments
 (0)