diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt index 4c48ca7b3a2..253e9f26c96 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt @@ -65,8 +65,6 @@ class ResultTypeResolver( } } - if (direction == ResolveDirection.TO_SUBTYPE) return builtIns.nothingType - // direction == TO_SUPER or there is no LOWER bounds val upperConstraints = variableWithConstraints.constraints.filter { it.kind == ConstraintKind.UPPER && c.isProperType(it.type) } if (upperConstraints.isNotEmpty()) { @@ -75,7 +73,13 @@ class ResultTypeResolver( return typeApproximator.approximateToSubType(upperType, TypeApproximatorConfiguration.CapturedTypesApproximation) ?: upperType } - return builtIns.anyType + // no proper constraints + if (direction == ResolveDirection.TO_SUBTYPE) { + return builtIns.nothingType + } + else { + return builtIns.anyType + } } fun findResultIfThereIsEqualsConstraint(