From dfe0059b242bd490d006f8304926f559362eb5e9 Mon Sep 17 00:00:00 2001 From: Błażej Kardyś Date: Thu, 12 Mar 2020 10:56:17 +0100 Subject: Fixing variance in psi parsing --- .../translators/psi/DefaultPsiToDocumentableTranslator.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'plugins/base/src') diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index 8bf556af..65f94843 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -260,7 +260,17 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { } } - private fun getProjection(type: PsiType): Projection = if (type is PsiEllipsisType) Star else getBound(type) + private fun getVariance(type: PsiWildcardType): Projection = when { + type.extendsBound != PsiType.NULL -> Variance(Variance.Kind.Out, getBound(type.extendsBound)) + type.superBound != PsiType.NULL -> Variance(Variance.Kind.In, getBound(type.superBound)) + else -> throw IllegalStateException("${type.presentableText} has incorrect bounds") + } + + private fun getProjection(type: PsiType): Projection = when (type) { + is PsiEllipsisType -> Star + is PsiWildcardType -> getVariance(type) + else -> getBound(type) + } private fun PsiModifierListOwner.getModifier() = when { hasModifier(JvmModifier.ABSTRACT) -> JavaModifier.Abstract -- cgit