Minor: cleanup + support variance in ErrorListDiagnosticListRenderer

1. Support variance in ErrorListDiagnosticListRenderer.
   I will make some diagnostics to have covariant type arguments in the
   next commits
2. Drop unused code

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
This commit is contained in:
Nikita Bobko
2023-10-16 11:59:20 +02:00
committed by teamcity
parent 3b47610817
commit a3401b2f9e
2 changed files with 6 additions and 8 deletions
@@ -13,6 +13,7 @@ import java.io.File
import kotlin.reflect.KClass import kotlin.reflect.KClass
import kotlin.reflect.KType import kotlin.reflect.KType
import kotlin.reflect.KTypeProjection import kotlin.reflect.KTypeProjection
import kotlin.reflect.KVariance
object ErrorListDiagnosticListRenderer : DiagnosticListRenderer() { object ErrorListDiagnosticListRenderer : DiagnosticListRenderer() {
const val BASE_PACKAGE = "org.jetbrains.kotlin.fir.analysis.diagnostics" const val BASE_PACKAGE = "org.jetbrains.kotlin.fir.analysis.diagnostics"
@@ -116,6 +117,11 @@ object ErrorListDiagnosticListRenderer : DiagnosticListRenderer() {
if (typeArgumentType == null) { if (typeArgumentType == null) {
print("*") print("*")
} else { } else {
when (typeArgument.variance) {
KVariance.INVARIANT, null -> {}
KVariance.IN -> print("in ")
KVariance.OUT -> print("out ")
}
printType(typeArgumentType) printType(typeArgumentType)
} }
} }
@@ -105,11 +105,3 @@ val ExpectActualCompatibility<*>.isCompatibleOrWeaklyIncompatible: Boolean
val ExpectActualCompatibility<*>.compatible: Boolean val ExpectActualCompatibility<*>.compatible: Boolean
get() = this == ExpectActualCompatibility.Compatible get() = this == ExpectActualCompatibility.Compatible
@OptIn(ExperimentalContracts::class)
fun ExpectActualCompatibility<*>.isIncompatible(): Boolean {
contract {
returns(true) implies (this@isIncompatible is ExpectActualCompatibility.Incompatible<*>)
}
return !compatible
}