Add some error handling

This commit is contained in:
Tamas Vajk
2022-02-15 17:50:54 +01:00
committed by Ian Lynagh
parent a598c7fc0c
commit 8ab4335562

View File

@@ -2917,8 +2917,22 @@ open class KotlinFileExtractor(
}
val functionType = if (e.argument.type.isKFunction()) {
// todo: add error handling to the below
getFunctionalInterfaceType((e.argument.type as IrSimpleType).arguments.filterIsInstance<IrTypeProjection>().map { it.type })
val st = e.argument.type as? IrSimpleType
if (st == null) {
logger.errorElement("Expected to find a simple type in SAM conversion.", e)
return
}
val typeArgs = mutableListOf<IrType>()
for (arg in st.arguments) {
if (arg !is IrTypeProjection) {
logger.errorElement("Expected to find only type projections in SAM conversion.", e)
return
}
typeArgs.add(arg.type)
}
getFunctionalInterfaceType(typeArgs)
} else {
e.argument.type
}