From 33e11b3014bd81d598399c356e7e2ed3dce69a04 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Tue, 7 Jun 2022 11:11:00 +0100 Subject: [PATCH] Kotlin: Simplify samMember computation --- .../src/main/kotlin/KotlinFileExtractor.kt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt index 22e45ed2d44..7644cbb1729 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt @@ -4057,17 +4057,14 @@ open class KotlinFileExtractor( } val typeOwner = e.typeOperandClassifier.owner - val samMember = if (typeOwner !is IrClass) { + if (typeOwner !is IrClass) { logger.errorElement("Expected to find SAM conversion to IrClass. Found '${typeOwner.javaClass}' instead. Can't implement SAM interface.", e) return - } else { - val samMember = typeOwner.declarations.filterIsInstance().find { it is IrOverridableMember && it.modality == Modality.ABSTRACT } - if (samMember == null) { - logger.errorElement("Couldn't find SAM member in type '${typeOwner.kotlinFqName.asString()}'. Can't implement SAM interface.", e) - return - } else { - samMember - } + } + val samMember = typeOwner.declarations.filterIsInstance().find { it is IrOverridableMember && it.modality == Modality.ABSTRACT } + if (samMember == null) { + logger.errorElement("Couldn't find SAM member in type '${typeOwner.kotlinFqName.asString()}'. Can't implement SAM interface.", e) + return } val javaResult = TypeResult(tw.getFreshIdLabel(), "", "")