Render short names in constraint system tests
This commit is contained in:
@@ -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_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 arrow = if (bound.kind == LOWER_BOUND) ">: " else if (bound.kind == UPPER_BOUND) "<: " else ":= "
|
||||
val type = arrow + RENDER_TYPE.render(bound.constrainingType)
|
||||
if (renderPosition) type + '(' + bound.position + ')' else type
|
||||
val renderer = if (short) DescriptorRenderer.SHORT_NAMES_IN_TYPES else DescriptorRenderer.FQ_NAMES_IN_TYPES
|
||||
val renderedBound = arrow + renderer.renderType(bound.constrainingType)
|
||||
if (short) renderedBound else renderedBound + '(' + bound.position + ')'
|
||||
}
|
||||
val typeVariableName = typeBounds.typeVariable.getName()
|
||||
return if (typeBounds.bounds.isEmpty()) {
|
||||
@@ -379,8 +380,8 @@ public object Renderers {
|
||||
"$typeVariableName ${StringUtil.join(typeBounds.bounds, renderBound, ", ")}"
|
||||
}
|
||||
|
||||
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) }
|
||||
public val RENDER_TYPE_BOUNDS: Renderer<TypeBounds> = Renderer { renderTypeBounds(it, short = false) }
|
||||
public val RENDER_TYPE_BOUNDS_SHORT: Renderer<TypeBounds> = Renderer { renderTypeBounds(it, short = true) }
|
||||
|
||||
private fun renderDebugMessage(message: String, inferenceErrorData: InferenceErrorData) = StringBuilder {
|
||||
append(message)
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ SUBTYPE T Int
|
||||
SUPERTYPE T String
|
||||
|
||||
type parameter bounds:
|
||||
T <: kotlin.Int, >: kotlin.String
|
||||
T <: Int, >: String
|
||||
|
||||
status:
|
||||
-hasCannotCaptureTypesError: false
|
||||
|
||||
@@ -4,7 +4,7 @@ SUBTYPE T Int
|
||||
SUPERTYPE T Int
|
||||
|
||||
type parameter bounds:
|
||||
T <: kotlin.Int, >: kotlin.Int
|
||||
T <: Int, >: Int
|
||||
|
||||
status:
|
||||
-hasCannotCaptureTypesError: false
|
||||
@@ -17,4 +17,4 @@ status:
|
||||
-isSuccessful: true
|
||||
|
||||
result:
|
||||
T=kotlin.Int
|
||||
T=Int
|
||||
@@ -4,7 +4,7 @@ SUBTYPE T Int
|
||||
SUBTYPE T String weak
|
||||
|
||||
type parameter bounds:
|
||||
T <: kotlin.Int, <: kotlin.String
|
||||
T <: Int, <: String
|
||||
|
||||
status:
|
||||
-hasCannotCaptureTypesError: false
|
||||
|
||||
@@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1000)
|
||||
SUBTYPE T Byte
|
||||
|
||||
type parameter bounds:
|
||||
T >: IntegerValueType(1000), <: kotlin.Byte
|
||||
T >: IntegerValueType(1000), <: Byte
|
||||
|
||||
status:
|
||||
-hasCannotCaptureTypesError: false
|
||||
|
||||
@@ -17,4 +17,4 @@ status:
|
||||
-isSuccessful: true
|
||||
|
||||
result:
|
||||
T=kotlin.Long
|
||||
T=Long
|
||||
@@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1)
|
||||
SUBTYPE T Any
|
||||
|
||||
type parameter bounds:
|
||||
T >: IntegerValueType(1), <: kotlin.Any
|
||||
T >: IntegerValueType(1), <: Any
|
||||
|
||||
status:
|
||||
-hasCannotCaptureTypesError: false
|
||||
@@ -17,4 +17,4 @@ status:
|
||||
-isSuccessful: true
|
||||
|
||||
result:
|
||||
T=kotlin.Int
|
||||
T=Int
|
||||
+2
-2
@@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1)
|
||||
SUPERTYPE T String
|
||||
|
||||
type parameter bounds:
|
||||
T >: IntegerValueType(1), >: kotlin.String
|
||||
T >: IntegerValueType(1), >: String
|
||||
|
||||
status:
|
||||
-hasCannotCaptureTypesError: false
|
||||
@@ -17,4 +17,4 @@ status:
|
||||
-isSuccessful: true
|
||||
|
||||
result:
|
||||
T=kotlin.Comparable<out kotlin.Any?>
|
||||
T=Comparable<out Any?>
|
||||
@@ -17,4 +17,4 @@ status:
|
||||
-isSuccessful: true
|
||||
|
||||
result:
|
||||
T=kotlin.Int
|
||||
T=Int
|
||||
@@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1)
|
||||
SUBTYPE T Byte
|
||||
|
||||
type parameter bounds:
|
||||
T >: IntegerValueType(1), <: kotlin.Byte
|
||||
T >: IntegerValueType(1), <: Byte
|
||||
|
||||
status:
|
||||
-hasCannotCaptureTypesError: false
|
||||
@@ -17,4 +17,4 @@ status:
|
||||
-isSuccessful: true
|
||||
|
||||
result:
|
||||
T=kotlin.Byte
|
||||
T=Byte
|
||||
@@ -16,4 +16,4 @@ status:
|
||||
-isSuccessful: true
|
||||
|
||||
result:
|
||||
T=kotlin.Int
|
||||
T=Int
|
||||
@@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1)
|
||||
SUBTYPE T Short
|
||||
|
||||
type parameter bounds:
|
||||
T >: IntegerValueType(1), <: kotlin.Short
|
||||
T >: IntegerValueType(1), <: Short
|
||||
|
||||
status:
|
||||
-hasCannotCaptureTypesError: false
|
||||
@@ -17,4 +17,4 @@ status:
|
||||
-isSuccessful: true
|
||||
|
||||
result:
|
||||
T=kotlin.Short
|
||||
T=Short
|
||||
+4
-5
@@ -3,8 +3,8 @@ VARIABLES T P
|
||||
SUBTYPE T Int
|
||||
|
||||
type parameter bounds:
|
||||
T <: kotlin.Int
|
||||
P <: kotlin.Int
|
||||
T <: Int
|
||||
P <: Int
|
||||
|
||||
status:
|
||||
-hasCannotCaptureTypesError: false
|
||||
@@ -17,6 +17,5 @@ status:
|
||||
-isSuccessful: true
|
||||
|
||||
result:
|
||||
T=kotlin.Int
|
||||
P=kotlin.Int
|
||||
|
||||
T=Int
|
||||
P=Int
|
||||
+2
-1
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.constraintSystem
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.Renderers
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.resolve.TypeResolver
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.SPECIAL
|
||||
@@ -108,7 +109,7 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() {
|
||||
for ((typeParameter, variance) in typeParameterDescriptors) {
|
||||
val parameterType = testDeclarations.getType(typeParameter.getName().asString())
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user