From d06b3a17bb98dc95526e0bbf07a9d591bd802ccb Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Mon, 15 Aug 2022 15:01:48 +0100 Subject: [PATCH] Kotlin: Remove a non-null-expr --- .../src/main/kotlin/KotlinFileExtractor.kt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt index ac019c99b32..45f841d6816 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt @@ -4515,14 +4515,19 @@ open class KotlinFileExtractor( tw.writeHasLocation(constructorBlockId, locId) // Super call - val superCallId = tw.getFreshIdLabel() - tw.writeStmts_superconstructorinvocationstmt(superCallId, constructorBlockId, 0, ids.constructor) + val baseClass = superTypes.first().classOrNull + if (baseClass == null) { + logger.warnElement("Cannot find base class", currentDeclaration) + } else { + val superCallId = tw.getFreshIdLabel() + tw.writeStmts_superconstructorinvocationstmt(superCallId, constructorBlockId, 0, ids.constructor) - val baseConstructor = superTypes.first().classOrNull!!.owner.declarations.find { it is IrFunction && it.symbol is IrConstructorSymbol } - val baseConstructorId = useFunction(baseConstructor as IrFunction) + val baseConstructor = baseClass.owner.declarations.find { it is IrFunction && it.symbol is IrConstructorSymbol } + val baseConstructorId = useFunction(baseConstructor as IrFunction) - tw.writeHasLocation(superCallId, locId) - tw.writeCallableBinding(superCallId.cast(), baseConstructorId) + tw.writeHasLocation(superCallId, locId) + tw.writeCallableBinding(superCallId.cast(), baseConstructorId) + } addModifiers(id, "final") addVisibilityModifierToLocalOrAnonymousClass(id)