diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt index f37ae53f661..0e24b91d302 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt @@ -69,7 +69,7 @@ private fun CallableDescriptor.hasReturnTypeDependentOnUninferredParams(constrai val returnType = getReturnType() ?: return false val nestedTypeVariables = with (constraintSystem as ConstraintSystemImpl) { - returnType.getNestedTypeVariables(original = true) + returnType.getNestedTypeVariables() } return nestedTypeVariables.any { constraintSystem.getTypeBounds(it).value == null } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt index 57a4c612e67..721629325d0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt @@ -164,7 +164,7 @@ class GenericCandidateResolver( val returnType = candidateDescriptor.getReturnType() ?: return false val nestedTypeVariables = with (argumentConstraintSystem) { - returnType.getNestedTypeVariables(original = true) + returnType.getNestedTypeVariables() } // we add an additional type variable only if no information is inferred for it. // otherwise we add currently inferred return type as before diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index c1e6393e37b..daf81d3b5f3 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -167,7 +167,7 @@ public class ConstraintSystemImpl : ConstraintSystem { type -> type.getConstructor().getDeclarationDescriptor() in getAllTypeVariables() } - fun JetType.getNestedTypeVariables(original: Boolean = false): List { + fun JetType.getNestedTypeVariables(original: Boolean = true): List { return getNestedArguments().map { typeProjection -> typeProjection.getType().getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor }.filterNotNull().filter { if (original) it in originalToVariables.keySet() else it in getAllTypeVariables() } @@ -344,7 +344,7 @@ public class ConstraintSystemImpl : ConstraintSystem { typeBounds.addBound(bound) if (!bound.isProper) { - for (dependentTypeVariable in bound.constrainingType.getNestedTypeVariables()) { + for (dependentTypeVariable in bound.constrainingType.getNestedTypeVariables(original = false)) { val dependentBounds = usedInBounds.getOrPut(dependentTypeVariable) { arrayListOf() } dependentBounds.add(bound) } @@ -477,7 +477,7 @@ public class ConstraintSystemImpl : ConstraintSystem { if (typeBounds.isFixed) return typeBounds.setFixed() - val nestedTypeVariables = typeBounds.bounds.flatMap { it.constrainingType.getNestedTypeVariables() } + val nestedTypeVariables = typeBounds.bounds.flatMap { it.constrainingType.getNestedTypeVariables(original = false) } nestedTypeVariables.forEach { fixVariable(it) } val value = typeBounds.value ?: return diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt index 25f289886bf..3abccc2ffde 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt @@ -89,7 +89,7 @@ private fun ConstraintSystemImpl.generateNewBound(bound: Bound, substitution: Bo fun addNewBound(newConstrainingType: JetType, newBoundKind: BoundKind) { // We don't generate new recursive constraints - val nestedTypeVariables = newConstrainingType.getNestedTypeVariables() + val nestedTypeVariables = newConstrainingType.getNestedTypeVariables(original = false) if (nestedTypeVariables.contains(bound.typeVariable)) return // We don't generate constraint if a type variable was substituted twice