Add diagnostic info to assertion on type argument consistency
This commit is contained in:
@@ -18,6 +18,8 @@ package org.jetbrains.kotlin.types.typesApproximation
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||||
|
import org.jetbrains.kotlin.renderer.ClassifierNamePolicy
|
||||||
|
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.CapturedTypeConstructor
|
import org.jetbrains.kotlin.resolve.calls.inference.CapturedTypeConstructor
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.isCaptured
|
import org.jetbrains.kotlin.resolve.calls.inference.isCaptured
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||||
@@ -41,7 +43,14 @@ private class TypeArgument(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun TypeArgument.toTypeProjection(): TypeProjection {
|
private fun TypeArgument.toTypeProjection(): TypeProjection {
|
||||||
assert(isConsistent) { "Only consistent enhanced type propection can be converted to type projection" }
|
assert(isConsistent) {
|
||||||
|
val descriptorRenderer = DescriptorRenderer.withOptions {
|
||||||
|
classifierNamePolicy = ClassifierNamePolicy.FULLY_QUALIFIED
|
||||||
|
}
|
||||||
|
"Only consistent enhanced type projection can be converted to type projection, but " +
|
||||||
|
"[${descriptorRenderer.render(typeParameter)}: <${descriptorRenderer.renderType(inProjection)}, ${descriptorRenderer.renderType(outProjection)}>]" +
|
||||||
|
" was found"
|
||||||
|
}
|
||||||
fun removeProjectionIfRedundant(variance: Variance) = if (variance == typeParameter.variance) Variance.INVARIANT else variance
|
fun removeProjectionIfRedundant(variance: Variance) = if (variance == typeParameter.variance) Variance.INVARIANT else variance
|
||||||
return when {
|
return when {
|
||||||
inProjection == outProjection -> TypeProjectionImpl(inProjection)
|
inProjection == outProjection -> TypeProjectionImpl(inProjection)
|
||||||
|
|||||||
Reference in New Issue
Block a user