Skip to content

Commit 2ecd9c9

Browse files
committed
Kotlin: Remove cast in extractGeneratedClass
It turns out that this was really behaving as a nullness check.
1 parent 4f7eb7b commit 2ecd9c9

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4653,14 +4653,18 @@ open class KotlinFileExtractor(
46534653
if (baseClass == null) {
46544654
logger.warnElement("Cannot find base class", currentDeclaration)
46554655
} else {
4656-
val superCallId = tw.getFreshIdLabel<DbSuperconstructorinvocationstmt>()
4657-
tw.writeStmts_superconstructorinvocationstmt(superCallId, constructorBlockId, 0, ids.constructor)
4658-
46594656
val baseConstructor = baseClass.owner.declarations.findSubType<IrFunction> { it.symbol is IrConstructorSymbol }
4660-
val baseConstructorId = useFunction<DbConstructor>(baseConstructor as IrFunction)
4657+
if (baseConstructor == null) {
4658+
logger.warnElement("Cannot find base constructor", currentDeclaration)
4659+
} else {
4660+
val superCallId = tw.getFreshIdLabel<DbSuperconstructorinvocationstmt>()
4661+
tw.writeStmts_superconstructorinvocationstmt(superCallId, constructorBlockId, 0, ids.constructor)
46614662

4662-
tw.writeHasLocation(superCallId, locId)
4663-
tw.writeCallableBinding(superCallId.cast<DbCaller>(), baseConstructorId)
4663+
val baseConstructorId = useFunction<DbConstructor>(baseConstructor)
4664+
4665+
tw.writeHasLocation(superCallId, locId)
4666+
tw.writeCallableBinding(superCallId.cast<DbCaller>(), baseConstructorId)
4667+
}
46644668
}
46654669

46664670
addModifiers(id, "final")

0 commit comments

Comments
 (0)