diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt index 2372940ebf2..45ab277a171 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt @@ -216,7 +216,7 @@ public object Renderers { ): TabledDescriptorRenderer { var firstUnknownParameter: TypeParameterDescriptor? = null for (typeParameter in inferenceErrorData.constraintSystem.getTypeVariables()) { - if (inferenceErrorData.constraintSystem.getTypeBounds(typeParameter).isEmpty()) { + if (inferenceErrorData.constraintSystem.getTypeBounds(typeParameter).values.isEmpty()) { firstUnknownParameter = typeParameter break } @@ -256,7 +256,7 @@ public object Renderers { return result } - val inferredValueForTypeParameter = systemWithoutWeakConstraints.getTypeBounds(typeParameterDescriptor).getValue() + val inferredValueForTypeParameter = systemWithoutWeakConstraints.getTypeBounds(typeParameterDescriptor).value if (inferredValueForTypeParameter == null) { LOG.error(renderDebugMessage("System without weak constraints is not successful, there is no value for type parameter " + typeParameterDescriptor.getName() + "\n: " + systemWithoutWeakConstraints, inferenceErrorData)) @@ -372,7 +372,7 @@ public object Renderers { if (renderPosition) type + '(' + bound.position + ')' else type } val typeVariableName = typeBounds.typeVariable.getName() - return if (typeBounds.isEmpty()) { + return if (typeBounds.bounds.isEmpty()) { typeVariableName.asString() } else 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 43c9479c5a8..968451918b4 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 @@ -68,9 +68,9 @@ public class ConstraintSystemImpl : ConstraintSystem { override fun hasViolatedUpperBound() = !isSuccessful() && getSystemWithoutWeakConstraints().getStatus().isSuccessful() - override fun hasConflictingConstraints() = typeParameterBounds.values().any { it.getValues().size() > 1 } + override fun hasConflictingConstraints() = typeParameterBounds.values().any { it.values.size() > 1 } - override fun hasUnknownParameters() = typeParameterBounds.values().any { it.isEmpty() } + override fun hasUnknownParameters() = typeParameterBounds.values().any { it.values.isEmpty() } override fun hasTypeConstructorMismatch() = errors.any { it is TypeConstructorMismatch } @@ -92,7 +92,7 @@ public class ConstraintSystemImpl : ConstraintSystem { val substitutionContext = HashMap() for ((typeParameter, typeBounds) in typeParameterBounds) { val typeProjection: TypeProjection - val value = typeBounds.getValue() + val value = typeBounds.value if (value != null && !TypeUtils.containsSpecialType(value, DONT_CARE)) { typeProjection = TypeProjectionImpl(value) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt index 5825ecac958..fc759a211a8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt @@ -28,11 +28,9 @@ public trait TypeBounds { public val bounds: Collection - public fun isEmpty(): Boolean + public val value: JetType? - public fun getValue(): JetType? - - public fun getValues(): Collection + public val values: Collection public enum class BoundKind { LOWER_BOUND, diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt index dcfbedd4970..2b921f82b4a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt @@ -45,10 +45,6 @@ public class TypeBoundsImpl( bounds.add(Bound(constrainingType, kind, position)) } - override fun isEmpty(): Boolean { - return getValues().isEmpty() - } - private fun filterBounds(bounds: Collection, kind: BoundKind): Set { return filterBounds(bounds, kind, null) } @@ -81,20 +77,16 @@ public class TypeBoundsImpl( return result } - override fun getValue(): JetType? { - val values = getValues() - if (values.size() == 1) { - return values.iterator().next() - } - return null - } + override val value: JetType? + get() = if (values.size() == 1) values.first() else null - override fun getValues(): Collection { - if (resultValues == null) { - resultValues = computeValues() + override val values: Collection + get() { + if (resultValues == null) { + resultValues = computeValues() + } + return resultValues!! } - return resultValues!! - } private fun computeValues(): Collection { val values = LinkedHashSet()