From 1ec620b7531f57011b7f5f72a8a70b1a2d77d1ea Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Fri, 11 Oct 2019 12:03:07 +0300 Subject: [PATCH] New J2K: fix SOE in inference processing for star-projection as type argument #KT-33942 fixed #KT-33941 fixed --- .../nj2k/inference/common/BoundTypeCalculator.kt | 11 ++++++----- nj2k/testData/inference/nullability/javaStream.kt | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/nj2k/nj2k-services/src/org/jetbrains/kotlin/nj2k/inference/common/BoundTypeCalculator.kt b/nj2k/nj2k-services/src/org/jetbrains/kotlin/nj2k/inference/common/BoundTypeCalculator.kt index 8bb27875082..9bad336ba93 100644 --- a/nj2k/nj2k-services/src/org/jetbrains/kotlin/nj2k/inference/common/BoundTypeCalculator.kt +++ b/nj2k/nj2k-services/src/org/jetbrains/kotlin/nj2k/inference/common/BoundTypeCalculator.kt @@ -204,16 +204,17 @@ open class BoundTypeCalculatorImpl( BoundTypeImpl( typeVariable?.let { TypeVariableLabel(it) } ?: GenericLabel(target.classReference), arguments.mapIndexed { i, argument -> - TypeParameter( - argument.type.boundTypeUnenhanced( + val argumentBoundType = when { + argument.isStarProjection -> BoundType.STAR_PROJECTION + else -> argument.type.boundTypeUnenhanced( typeVariable?.typeParameters?.getOrNull(i)?.boundType?.label?.safeAs()?.typeVariable, contextBoundType, call, isImplicitReceiver, inferenceContext - ) ?: return null, - constructor.parameters[i].variance - ) + ) ?: return null + } + TypeParameter(argumentBoundType, constructor.parameters[i].variance) } ) diff --git a/nj2k/testData/inference/nullability/javaStream.kt b/nj2k/testData/inference/nullability/javaStream.kt index ce251548442..27eec687350 100644 --- a/nj2k/testData/inference/nullability/javaStream.kt +++ b/nj2k/testData/inference/nullability/javaStream.kt @@ -7,7 +7,7 @@ import java.util.stream.Stream fun test(list: /*T1@*/List) { val x: /*T9@*/List = list/*T1@List*/.stream()/*Stream!!L*/ .map({ x: /*T2@*/String -> x/*T2@String*/ + ""/*LIT*//*LIT*/ }/*Function1!!L*/)/*Stream*/ - .collect, /*T7@*/Any>(Collectors/*LIT*/.toList()/*Collector>*/)/*T6@List*/ + .collect, /*T7@*/Any>(Collectors/*LIT*/.toList()/*Collector>*/)/*T6@List*/ }