diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityChecker.kt index 65f3e09caff..9a6254f7080 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityChecker.kt @@ -254,17 +254,17 @@ class JavaNullabilityChecker : AdditionalTypeChecker { null } - @OptIn(ExperimentalStdlibApi::class) private fun enhanceTypeArguments(arguments: List) = - buildList { - for (argument in arguments) { - // TODO: think about star projections with enhancement (e.g. came from Java: Foo<@NotNull ?>) - if (argument.isStarProjection) continue - val argumentType = argument.type - val enhancedArgumentType = if (argumentType is TypeWithEnhancement) argumentType.enhancement else argumentType - val enhancedDeeplyArgumentType = buildTypeWithEnhancement(enhancedArgumentType) - add(argument.replaceType(enhancedDeeplyArgumentType)) + arguments.map { argument -> + // TODO: think about star projections with enhancement (e.g. came from Java: Foo<@NotNull ?>) + if (argument.isStarProjection) { + return@map argument } + val argumentType = argument.type + val enhancedArgumentType = if (argumentType is TypeWithEnhancement) argumentType.enhancement else argumentType + val enhancedDeeplyArgumentType = buildTypeWithEnhancement(enhancedArgumentType) + + argument.replaceType(enhancedDeeplyArgumentType) } fun buildTypeWithEnhancement(type: KotlinType): KotlinType {