mirror of
https://github.com/github/codeql.git
synced 2026-02-11 20:51:06 +01:00
Kotlin: Inline cast
This commit is contained in:
@@ -2975,10 +2975,11 @@ open class KotlinFileExtractor(
|
||||
val locId = tw.getLocation(s)
|
||||
tw.writeStmts_block(blockId, parent, idx, callable)
|
||||
tw.writeHasLocation(blockId, locId)
|
||||
// For Kotlin < 2.3, s.delegate is not-nullable. Cast to be nullable,
|
||||
// as a workaround to silence warnings for kotlin < 2.3 about the elvis
|
||||
// operator being redundant.
|
||||
val delegate: IrVariable? = cast(s.delegate)
|
||||
// For Kotlin < 2.3, s.delegate is not-nullable, but for Kotlin >= 2.3
|
||||
// it is nullable. Cast to nullable to handle both cases uniformly.
|
||||
// For Kotlin >= 2.3, the cast is redundant, hence the suppress.
|
||||
@Suppress("USELESS_CAST")
|
||||
val delegate: IrVariable? = s.delegate as IrVariable?
|
||||
val propId = tw.getFreshIdLabel<DbKt_property>()
|
||||
|
||||
if (delegate == null) {
|
||||
|
||||
@@ -11,6 +11,3 @@ fun IrFunction.isLocalFunction(): Boolean {
|
||||
|
||||
val IrClass.isInterfaceLike
|
||||
get() = kind == ClassKind.INTERFACE || kind == ClassKind.ANNOTATION_CLASS
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> cast(value: Any?): T = value as T
|
||||
|
||||
Reference in New Issue
Block a user