Render short names in constraint system tests

This commit is contained in:
Svetlana Isakova
2015-05-11 12:57:54 +02:00
parent 8b9cdd1751
commit 0fdfb6b5db
14 changed files with 28 additions and 27 deletions
@@ -365,11 +365,12 @@ public object Renderers {
public val RENDER_CONSTRAINT_SYSTEM: Renderer<ConstraintSystem> = Renderer { renderConstraintSystem(it, RENDER_TYPE_BOUNDS) } 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) } public val RENDER_CONSTRAINT_SYSTEM_SHORT: Renderer<ConstraintSystem> = Renderer { renderConstraintSystem(it, RENDER_TYPE_BOUNDS_SHORT) }
private fun renderTypeBounds(typeBounds: TypeBounds, renderPosition: Boolean): String { private fun renderTypeBounds(typeBounds: TypeBounds, short: Boolean): String {
val renderBound = { bound: Bound -> val renderBound = { bound: Bound ->
val arrow = if (bound.kind == LOWER_BOUND) ">: " else if (bound.kind == UPPER_BOUND) "<: " else ":= " val arrow = if (bound.kind == LOWER_BOUND) ">: " else if (bound.kind == UPPER_BOUND) "<: " else ":= "
val type = arrow + RENDER_TYPE.render(bound.constrainingType) val renderer = if (short) DescriptorRenderer.SHORT_NAMES_IN_TYPES else DescriptorRenderer.FQ_NAMES_IN_TYPES
if (renderPosition) type + '(' + bound.position + ')' else type val renderedBound = arrow + renderer.renderType(bound.constrainingType)
if (short) renderedBound else renderedBound + '(' + bound.position + ')'
} }
val typeVariableName = typeBounds.typeVariable.getName() val typeVariableName = typeBounds.typeVariable.getName()
return if (typeBounds.bounds.isEmpty()) { return if (typeBounds.bounds.isEmpty()) {
@@ -379,8 +380,8 @@ public object Renderers {
"$typeVariableName ${StringUtil.join(typeBounds.bounds, renderBound, ", ")}" "$typeVariableName ${StringUtil.join(typeBounds.bounds, renderBound, ", ")}"
} }
public val RENDER_TYPE_BOUNDS: Renderer<TypeBounds> = Renderer { renderTypeBounds(it, renderPosition = true) } public val RENDER_TYPE_BOUNDS: Renderer<TypeBounds> = Renderer { renderTypeBounds(it, short = false) }
public val RENDER_TYPE_BOUNDS_SHORT: Renderer<TypeBounds> = Renderer { renderTypeBounds(it, renderPosition = false) } public val RENDER_TYPE_BOUNDS_SHORT: Renderer<TypeBounds> = Renderer { renderTypeBounds(it, short = true) }
private fun renderDebugMessage(message: String, inferenceErrorData: InferenceErrorData) = StringBuilder { private fun renderDebugMessage(message: String, inferenceErrorData: InferenceErrorData) = StringBuilder {
append(message) append(message)
@@ -4,7 +4,7 @@ SUBTYPE T Int
SUPERTYPE T String SUPERTYPE T String
type parameter bounds: type parameter bounds:
T <: kotlin.Int, >: kotlin.String T <: Int, >: String
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
@@ -4,7 +4,7 @@ SUBTYPE T Int
SUPERTYPE T Int SUPERTYPE T Int
type parameter bounds: type parameter bounds:
T <: kotlin.Int, >: kotlin.Int T <: Int, >: Int
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
@@ -17,4 +17,4 @@ status:
-isSuccessful: true -isSuccessful: true
result: result:
T=kotlin.Int T=Int
@@ -4,7 +4,7 @@ SUBTYPE T Int
SUBTYPE T String weak SUBTYPE T String weak
type parameter bounds: type parameter bounds:
T <: kotlin.Int, <: kotlin.String T <: Int, <: String
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
@@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1000)
SUBTYPE T Byte SUBTYPE T Byte
type parameter bounds: type parameter bounds:
T >: IntegerValueType(1000), <: kotlin.Byte T >: IntegerValueType(1000), <: Byte
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
@@ -17,4 +17,4 @@ status:
-isSuccessful: true -isSuccessful: true
result: result:
T=kotlin.Long T=Long
@@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1)
SUBTYPE T Any SUBTYPE T Any
type parameter bounds: type parameter bounds:
T >: IntegerValueType(1), <: kotlin.Any T >: IntegerValueType(1), <: Any
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
@@ -17,4 +17,4 @@ status:
-isSuccessful: true -isSuccessful: true
result: result:
T=kotlin.Int T=Int
@@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1)
SUPERTYPE T String SUPERTYPE T String
type parameter bounds: type parameter bounds:
T >: IntegerValueType(1), >: kotlin.String T >: IntegerValueType(1), >: String
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
@@ -17,4 +17,4 @@ status:
-isSuccessful: true -isSuccessful: true
result: result:
T=kotlin.Comparable<out kotlin.Any?> T=Comparable<out Any?>
@@ -17,4 +17,4 @@ status:
-isSuccessful: true -isSuccessful: true
result: result:
T=kotlin.Int T=Int
@@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1)
SUBTYPE T Byte SUBTYPE T Byte
type parameter bounds: type parameter bounds:
T >: IntegerValueType(1), <: kotlin.Byte T >: IntegerValueType(1), <: Byte
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
@@ -17,4 +17,4 @@ status:
-isSuccessful: true -isSuccessful: true
result: result:
T=kotlin.Byte T=Byte
@@ -16,4 +16,4 @@ status:
-isSuccessful: true -isSuccessful: true
result: result:
T=kotlin.Int T=Int
@@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1)
SUBTYPE T Short SUBTYPE T Short
type parameter bounds: type parameter bounds:
T >: IntegerValueType(1), <: kotlin.Short T >: IntegerValueType(1), <: Short
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
@@ -17,4 +17,4 @@ status:
-isSuccessful: true -isSuccessful: true
result: result:
T=kotlin.Short T=Short
@@ -3,8 +3,8 @@ VARIABLES T P
SUBTYPE T Int SUBTYPE T Int
type parameter bounds: type parameter bounds:
T <: kotlin.Int T <: Int
P <: kotlin.Int P <: Int
status: status:
-hasCannotCaptureTypesError: false -hasCannotCaptureTypesError: false
@@ -17,6 +17,5 @@ status:
-isSuccessful: true -isSuccessful: true
result: result:
T=kotlin.Int T=Int
P=kotlin.Int P=Int
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.constraintSystem
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.diagnostics.rendering.Renderers import org.jetbrains.kotlin.diagnostics.rendering.Renderers
import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.resolve.TypeResolver import org.jetbrains.kotlin.resolve.TypeResolver
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.SPECIAL import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.SPECIAL
@@ -108,7 +109,7 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() {
for ((typeParameter, variance) in typeParameterDescriptors) { for ((typeParameter, variance) in typeParameterDescriptors) {
val parameterType = testDeclarations.getType(typeParameter.getName().asString()) val parameterType = testDeclarations.getType(typeParameter.getName().asString())
val resultType = resultingSubstitutor.substitute(parameterType, variance) val resultType = resultingSubstitutor.substitute(parameterType, variance)
result append "${typeParameter.getName()}=${resultType?.let{ Renderers.RENDER_TYPE.render(it) }}\n" result append "${typeParameter.getName()}=${resultType?.let{ DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(it) }}\n"
} }
JetTestUtils.assertEqualsToFile(file, "${getConstraintsText(fileText)}${resultingStatus}\n\n${result}\n") JetTestUtils.assertEqualsToFile(file, "${getConstraintsText(fileText)}${resultingStatus}\n\n${result}\n")