Skip to content

Commit 43a553d

Browse files
authored
Merge pull request #10279 from igfoo/igfoo/extractGeneratedClass
Kotlin: Remove cast in extractGeneratedClass
2 parents c239871 + 2ecd9c9 commit 43a553d

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
@@ -4669,14 +4669,18 @@ open class KotlinFileExtractor(
46694669
if (baseClass == null) {
46704670
logger.warnElement("Cannot find base class", currentDeclaration)
46714671
} else {
4672-
val superCallId = tw.getFreshIdLabel<DbSuperconstructorinvocationstmt>()
4673-
tw.writeStmts_superconstructorinvocationstmt(superCallId, constructorBlockId, 0, ids.constructor)
4674-
46754672
val baseConstructor = baseClass.owner.declarations.findSubType<IrFunction> { it.symbol is IrConstructorSymbol }
4676-
val baseConstructorId = useFunction<DbConstructor>(baseConstructor as IrFunction)
4673+
if (baseConstructor == null) {
4674+
logger.warnElement("Cannot find base constructor", currentDeclaration)
4675+
} else {
4676+
val superCallId = tw.getFreshIdLabel<DbSuperconstructorinvocationstmt>()
4677+
tw.writeStmts_superconstructorinvocationstmt(superCallId, constructorBlockId, 0, ids.constructor)
46774678

4678-
tw.writeHasLocation(superCallId, locId)
4679-
tw.writeCallableBinding(superCallId.cast<DbCaller>(), baseConstructorId)
4679+
val baseConstructorId = useFunction<DbConstructor>(baseConstructor)
4680+
4681+
tw.writeHasLocation(superCallId, locId)
4682+
tw.writeCallableBinding(superCallId.cast<DbCaller>(), baseConstructorId)
4683+
}
46804684
}
46814685

46824686
addModifiers(id, "final")

0 commit comments

Comments
 (0)