Skip to content

Commit 3905522

Browse files
committed
Add diagnostic info to assertion on type argument consistency
1 parent 830bf62 commit 3905522

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ package org.jetbrains.kotlin.types.typesApproximation
1818

1919
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
2020
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
21+
import org.jetbrains.kotlin.renderer.ClassifierNamePolicy
22+
import org.jetbrains.kotlin.renderer.DescriptorRenderer
2123
import org.jetbrains.kotlin.resolve.calls.inference.CapturedTypeConstructor
2224
import org.jetbrains.kotlin.resolve.calls.inference.isCaptured
2325
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
@@ -41,7 +43,14 @@ private class TypeArgument(
4143
}
4244

4345
private fun TypeArgument.toTypeProjection(): TypeProjection {
44-
assert(isConsistent) { "Only consistent enhanced type propection can be converted to type projection" }
46+
assert(isConsistent) {
47+
val descriptorRenderer = DescriptorRenderer.withOptions {
48+
classifierNamePolicy = ClassifierNamePolicy.FULLY_QUALIFIED
49+
}
50+
"Only consistent enhanced type projection can be converted to type projection, but " +
51+
"[${descriptorRenderer.render(typeParameter)}: <${descriptorRenderer.renderType(inProjection)}, ${descriptorRenderer.renderType(outProjection)}>]" +
52+
" was found"
53+
}
4554
fun removeProjectionIfRedundant(variance: Variance) = if (variance == typeParameter.variance) Variance.INVARIANT else variance
4655
return when {
4756
inProjection == outProjection -> TypeProjectionImpl(inProjection)

0 commit comments

Comments
 (0)