Don't render constraint positions in tests

for constraint system, it's always SPECIAL anyway
This commit is contained in:
Svetlana Isakova
2015-05-09 11:37:30 +02:00
parent f7dc59e2d6
commit 918087f475
21 changed files with 30 additions and 27 deletions
@@ -351,23 +351,25 @@ public object Renderers {
public val RENDER_COLLECTION_OF_TYPES: Renderer<Collection<JetType>> = Renderer { renderTypes(it) }
private fun renderConstraintSystem(constraintSystem: ConstraintSystem): String {
private fun renderConstraintSystem(constraintSystem: ConstraintSystem, renderTypeBounds: Renderer<TypeBounds>): String {
val typeVariables = constraintSystem.getTypeVariables()
val typeBounds = Sets.newLinkedHashSet<TypeBounds>()
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<ConstraintSystem> = Renderer { renderConstraintSystem(it) }
public val RENDER_CONSTRAINT_SYSTEM: Renderer<ConstraintSystem> = Renderer { renderConstraintSystem(it, RENDER_TYPE_BOUNDS) }
public val RENDER_CONSTRAINT_SYSTEM_SHORT: Renderer<ConstraintSystem> = 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<TypeBounds> = Renderer { renderTypeBounds(it) }
public val RENDER_TYPE_BOUNDS: Renderer<TypeBounds> = Renderer { renderTypeBounds(it, renderPosition = true) }
public val RENDER_TYPE_BOUNDS_SHORT: Renderer<TypeBounds> = Renderer { renderTypeBounds(it, renderPosition = false) }
private fun renderDebugMessage(message: String, inferenceErrorData: InferenceErrorData) = StringBuilder {
append(message)
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -3,7 +3,7 @@ VARIABLES T
SUBTYPE Consumer<A> Consumer<T>
type parameter bounds:
T <: A(SPECIAL)
T <: A
status:
-hasCannotCaptureTypesError: false
-hasConflictingConstraints: false
@@ -3,7 +3,7 @@ VARIABLES T
SUBTYPE My<T> My<A>
type parameter bounds:
T := A(SPECIAL)
T := A
status:
-hasCannotCaptureTypesError: false
-hasConflictingConstraints: false
@@ -3,7 +3,7 @@ VARIABLES T
SUBTYPE Producer<A> Producer<T>
type parameter bounds:
T >: A(SPECIAL)
T >: A
status:
-hasCannotCaptureTypesError: false
-hasConflictingConstraints: false
@@ -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"