Skip to content

Commit d06b3a1

Browse files
committed
Kotlin: Remove a non-null-expr
1 parent 40334a2 commit d06b3a1

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4515,14 +4515,19 @@ open class KotlinFileExtractor(
45154515
tw.writeHasLocation(constructorBlockId, locId)
45164516

45174517
// Super call
4518-
val superCallId = tw.getFreshIdLabel<DbSuperconstructorinvocationstmt>()
4519-
tw.writeStmts_superconstructorinvocationstmt(superCallId, constructorBlockId, 0, ids.constructor)
4518+
val baseClass = superTypes.first().classOrNull
4519+
if (baseClass == null) {
4520+
logger.warnElement("Cannot find base class", currentDeclaration)
4521+
} else {
4522+
val superCallId = tw.getFreshIdLabel<DbSuperconstructorinvocationstmt>()
4523+
tw.writeStmts_superconstructorinvocationstmt(superCallId, constructorBlockId, 0, ids.constructor)
45204524

4521-
val baseConstructor = superTypes.first().classOrNull!!.owner.declarations.find { it is IrFunction && it.symbol is IrConstructorSymbol }
4522-
val baseConstructorId = useFunction<DbConstructor>(baseConstructor as IrFunction)
4525+
val baseConstructor = baseClass.owner.declarations.find { it is IrFunction && it.symbol is IrConstructorSymbol }
4526+
val baseConstructorId = useFunction<DbConstructor>(baseConstructor as IrFunction)
45234527

4524-
tw.writeHasLocation(superCallId, locId)
4525-
tw.writeCallableBinding(superCallId.cast<DbCaller>(), baseConstructorId)
4528+
tw.writeHasLocation(superCallId, locId)
4529+
tw.writeCallableBinding(superCallId.cast<DbCaller>(), baseConstructorId)
4530+
}
45264531

45274532
addModifiers(id, "final")
45284533
addVisibilityModifierToLocalOrAnonymousClass(id)

0 commit comments

Comments
 (0)