From 7eabdeffb387973c7df20f43d85ed3826cfc5b93 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Wed, 24 May 2017 14:55:43 +0300 Subject: [PATCH] [NI] Fix variable to proper upper type even if direction is TO_SUBTYPE. --- .../calls/inference/components/ResultTypeResolver.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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(