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 40c26d70b52..308617d8603 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt @@ -351,23 +351,25 @@ public object Renderers { public val RENDER_COLLECTION_OF_TYPES: Renderer> = Renderer { renderTypes(it) } - private fun renderConstraintSystem(constraintSystem: ConstraintSystem): String { + private fun renderConstraintSystem(constraintSystem: ConstraintSystem, renderTypeBounds: Renderer): String { val typeVariables = constraintSystem.getTypeVariables() val typeBounds = Sets.newLinkedHashSet() for (variable in typeVariables) { typeBounds.add(constraintSystem.getTypeBounds(variable)) } return "type parameter bounds:\n" + - StringUtil.join(typeBounds, { RENDER_TYPE_BOUNDS.render(it) }, "\n") + "\n" + "status:\n" + + StringUtil.join(typeBounds, { renderTypeBounds.render(it) }, "\n") + "\n" + "status:\n" + ConstraintsUtil.getDebugMessageForStatus(constraintSystem.getStatus()) } - public val RENDER_CONSTRAINT_SYSTEM: Renderer = Renderer { renderConstraintSystem(it) } + public val RENDER_CONSTRAINT_SYSTEM: Renderer = Renderer { renderConstraintSystem(it, RENDER_TYPE_BOUNDS) } + public val RENDER_CONSTRAINT_SYSTEM_SHORT: Renderer = Renderer { renderConstraintSystem(it, RENDER_TYPE_BOUNDS_SHORT) } - private fun renderTypeBounds(typeBounds: TypeBounds): String { + private fun renderTypeBounds(typeBounds: TypeBounds, renderPosition: Boolean): String { val renderBound = { bound: Bound -> val arrow = if (bound.kind == LOWER_BOUND) ">: " else if (bound.kind == UPPER_BOUND) "<: " else ":= " - arrow + RENDER_TYPE.render(bound.constrainingType) + '(' + bound.position + ')' + val type = arrow + RENDER_TYPE.render(bound.constrainingType) + if (renderPosition) type + '(' + bound.position + ')' else type } val typeVariableName = typeBounds.typeVariable.getName() return if (typeBounds.isEmpty()) { @@ -377,7 +379,8 @@ public object Renderers { "$typeVariableName ${StringUtil.join(typeBounds.bounds, renderBound, ", ")}" } - public val RENDER_TYPE_BOUNDS: Renderer = Renderer { renderTypeBounds(it) } + public val RENDER_TYPE_BOUNDS: Renderer = Renderer { renderTypeBounds(it, renderPosition = true) } + public val RENDER_TYPE_BOUNDS_SHORT: Renderer = Renderer { renderTypeBounds(it, renderPosition = false) } private fun renderDebugMessage(message: String, inferenceErrorData: InferenceErrorData) = StringBuilder { append(message) diff --git a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds index 5c41241ab88..59640269ecb 100644 --- a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds +++ b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds @@ -4,7 +4,7 @@ SUBTYPE T Int SUPERTYPE T String type parameter bounds: -T <: kotlin.Int(SPECIAL), >: kotlin.String(SPECIAL) +T <: kotlin.Int, >: kotlin.String status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: true diff --git a/compiler/testData/constraintSystem/checkStatus/successful.bounds b/compiler/testData/constraintSystem/checkStatus/successful.bounds index bdc70204b1c..cf4f1a3cefc 100644 --- a/compiler/testData/constraintSystem/checkStatus/successful.bounds +++ b/compiler/testData/constraintSystem/checkStatus/successful.bounds @@ -4,7 +4,7 @@ SUBTYPE T Int SUPERTYPE T Int type parameter bounds: -T <: kotlin.Int(SPECIAL), >: kotlin.Int(SPECIAL) +T <: kotlin.Int, >: kotlin.Int status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds b/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds index b2e152f04dc..be6e0376645 100644 --- a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds +++ b/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds @@ -4,7 +4,7 @@ SUBTYPE T Int SUBTYPE T String weak type parameter bounds: -T <: kotlin.Int(SPECIAL), <: kotlin.String(TYPE_BOUND_POSITION(0)) +T <: kotlin.Int, <: kotlin.String status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: true diff --git a/compiler/testData/constraintSystem/computeValues/contradiction.bounds b/compiler/testData/constraintSystem/computeValues/contradiction.bounds index 923bf99606b..f01624d7886 100644 --- a/compiler/testData/constraintSystem/computeValues/contradiction.bounds +++ b/compiler/testData/constraintSystem/computeValues/contradiction.bounds @@ -4,7 +4,7 @@ SUBTYPE T B SUPERTYPE T A type parameter bounds: -T <: B(SPECIAL), >: A(SPECIAL) +T <: B, >: A status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: true diff --git a/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds b/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds index a9e09d438c8..61262df4092 100644 --- a/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds +++ b/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds @@ -4,7 +4,7 @@ SUBTYPE T A SUBTYPE T B type parameter bounds: -T <: A(SPECIAL), <: B(SPECIAL) +T <: A, <: B status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds index 584a66d7afb..742eefb1444 100644 --- a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds +++ b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds @@ -4,7 +4,7 @@ SUBTYPE T A SUPERTYPE T C type parameter bounds: -T <: A(SPECIAL), >: C(SPECIAL) +T <: A, >: C status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds index 318ac21cd9b..b126ccd2ba4 100644 --- a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds +++ b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds @@ -5,7 +5,7 @@ SUPERTYPE T B SUPERTYPE T C type parameter bounds: -T <: A(SPECIAL), >: B(SPECIAL), >: C(SPECIAL) +T <: A, >: B, >: C status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds index 94f27a74d2f..4e743ac9e1f 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1000) SUBTYPE T Byte type parameter bounds: -T >: IntegerValueType(1000)(SPECIAL), <: kotlin.Byte(SPECIAL) +T >: IntegerValueType(1000), <: kotlin.Byte status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: true diff --git a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds index b347c499c6d..5e3c96580b7 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1) SUPERTYPE T IntegerValueType(10000000000) type parameter bounds: -T >: IntegerValueType(1)(SPECIAL), >: IntegerValueType(10000000000)(SPECIAL) +T >: IntegerValueType(1), >: IntegerValueType(10000000000) status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds index adadb2fe28c..0b72b4a8149 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1) SUBTYPE T Any type parameter bounds: -T >: IntegerValueType(1)(SPECIAL), <: kotlin.Any(SPECIAL) +T >: IntegerValueType(1), <: kotlin.Any status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds index fdb976e6657..89d85abd655 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1) SUPERTYPE T String type parameter bounds: -T >: IntegerValueType(1)(SPECIAL), >: kotlin.String(SPECIAL) +T >: IntegerValueType(1), >: kotlin.String status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds index a42d6b14b06..01f148acb8d 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1) SUPERTYPE T IntegerValueType(1000) type parameter bounds: -T >: IntegerValueType(1)(SPECIAL), >: IntegerValueType(1000)(SPECIAL) +T >: IntegerValueType(1), >: IntegerValueType(1000) status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds index cc023a871ae..e52555bc4c1 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1) SUBTYPE T Byte type parameter bounds: -T >: IntegerValueType(1)(SPECIAL), <: kotlin.Byte(SPECIAL) +T >: IntegerValueType(1), <: kotlin.Byte status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds index a6961daeb68..0f81067b861 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds @@ -3,7 +3,7 @@ VARIABLES T SUPERTYPE T IntegerValueType(1) type parameter bounds: -T >: IntegerValueType(1)(SPECIAL) +T >: IntegerValueType(1) status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds index 04cdd23bcae..650c63014e9 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1) SUBTYPE T Short type parameter bounds: -T >: IntegerValueType(1)(SPECIAL), <: kotlin.Short(SPECIAL) +T >: IntegerValueType(1), <: kotlin.Short status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds b/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds index d8a26467e48..61c8b0259b7 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds @@ -3,8 +3,8 @@ VARIABLES T P SUBTYPE T Int type parameter bounds: -T <: kotlin.Int(SPECIAL) -P <: kotlin.Int(COMPOUND_CONSTRAINT_POSITION(TYPE_BOUND_POSITION(1), SPECIAL) +T <: kotlin.Int +P <: kotlin.Int status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/variance/consumer.bounds b/compiler/testData/constraintSystem/variance/consumer.bounds index 460d635c820..e411a250559 100644 --- a/compiler/testData/constraintSystem/variance/consumer.bounds +++ b/compiler/testData/constraintSystem/variance/consumer.bounds @@ -3,7 +3,7 @@ VARIABLES T SUBTYPE Consumer Consumer type parameter bounds: -T <: A(SPECIAL) +T <: A status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/variance/invariant.bounds b/compiler/testData/constraintSystem/variance/invariant.bounds index 957eb13f98b..68cd39ae8c9 100644 --- a/compiler/testData/constraintSystem/variance/invariant.bounds +++ b/compiler/testData/constraintSystem/variance/invariant.bounds @@ -3,7 +3,7 @@ VARIABLES T SUBTYPE My My type parameter bounds: -T := A(SPECIAL) +T := A status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/variance/producer.bounds b/compiler/testData/constraintSystem/variance/producer.bounds index 47b00045c22..77404015b57 100644 --- a/compiler/testData/constraintSystem/variance/producer.bounds +++ b/compiler/testData/constraintSystem/variance/producer.bounds @@ -3,7 +3,7 @@ VARIABLES T SUBTYPE Producer Producer type parameter bounds: -T >: A(SPECIAL) +T >: A status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt index 780dd7557e1..e8065aec277 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt @@ -101,7 +101,7 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { } constraintSystem.processDeclaredBoundConstraints() - val resultingStatus = Renderers.RENDER_CONSTRAINT_SYSTEM.render(constraintSystem) + val resultingStatus = Renderers.RENDER_CONSTRAINT_SYSTEM_SHORT.render(constraintSystem) val resultingSubstitutor = constraintSystem.getResultingSubstitutor() val result = StringBuilder() append "result:\n"