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 f705323b040..5c761448043 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt @@ -338,35 +338,38 @@ public object Renderers { }.toString() } - public val RENDER_COLLECTION_OF_TYPES: Renderer> = Renderer { - types -> StringUtil.join(types, { RENDER_TYPE.render(it) }, ", ") - } + private fun renderTypes(types: Collection) = StringUtil.join(types, { RENDER_TYPE.render(it) }, ", ") - public val RENDER_CONSTRAINT_SYSTEM: Renderer = Renderer { - (constraintSystem) -> + public val RENDER_COLLECTION_OF_TYPES: Renderer> = Renderer { renderTypes(it) } + + private fun renderConstraintSystem(constraintSystem: ConstraintSystem): String { val typeVariables = constraintSystem.getTypeVariables() val typeBounds = Sets.newLinkedHashSet() for (variable in typeVariables) { typeBounds.add(constraintSystem.getTypeBounds(variable)) } - "type parameter bounds:\n" + StringUtil.join(typeBounds, { RENDER_TYPE_BOUNDS.render(it) }, "\n") + "\n" + "status:\n" + - ConstraintsUtil.getDebugMessageForStatus(constraintSystem.getStatus()) + return "type parameter bounds:\n" + + StringUtil.join(typeBounds, { RENDER_TYPE_BOUNDS.render(it) }, "\n") + "\n" + "status:\n" + + ConstraintsUtil.getDebugMessageForStatus(constraintSystem.getStatus()) } - public val RENDER_TYPE_BOUNDS: Renderer = Renderer { - typeBounds -> + public val RENDER_CONSTRAINT_SYSTEM: Renderer = Renderer { renderConstraintSystem(it) } + + private fun renderTypeBounds(typeBounds: TypeBounds): 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 typeVariableName = typeBounds.typeVariable.getName() - if (typeBounds.isEmpty()) { + return if (typeBounds.isEmpty()) { typeVariableName.asString() } else "$typeVariableName ${StringUtil.join(typeBounds.bounds, renderBound, ", ")}" } + public val RENDER_TYPE_BOUNDS: Renderer = Renderer { renderTypeBounds(it) } + private fun renderDebugMessage(message: String, inferenceErrorData: InferenceErrorData) = StringBuilder { append(message) append("\nConstraint system: \n") @@ -384,6 +387,6 @@ public object Renderers { if (inferenceErrorData.receiverArgumentType != null) { append(RENDER_TYPE.render(inferenceErrorData.receiverArgumentType)).append(".") } - append("(").append(StringUtil.join(inferenceErrorData.valueArgumentsTypes, { RENDER_TYPE.render(it) }, ", ")).append(")") + append("(").append(renderTypes(inferenceErrorData.valueArgumentsTypes)).append(")") }.toString() } \ No newline at end of file