FIR LC: approximate local type only if it's necessary and out of scope

This commit is contained in:
Jinseong Jeon
2021-10-11 10:58:18 -07:00
committed by Roman Golyshev
parent 9ed2c9d371
commit 9524825662
9 changed files with 159 additions and 29 deletions
@@ -30,14 +30,14 @@ internal class KtFe10PsiTypeProvider(override val analysisSession: KtFe10Analysi
private val typeMapper by lazy { KtFe10JvmTypeMapperContext(analysisSession.resolveSession) }
override fun asPsiType(type: KtType, context: PsiElement, mode: TypeMappingMode): PsiType? = withValidityAssertion {
override fun asPsiType(type: KtType, useSitePosition: PsiElement, mode: TypeMappingMode): PsiType? = withValidityAssertion {
val kotlinType = (type as KtFe10Type).type
if (kotlinType.isError || kotlinType.arguments.any { !it.isStarProjection && it.type.isError }) {
return null
}
return asPsiType(simplifyType(kotlinType), context, mode)
return asPsiType(simplifyType(kotlinType), useSitePosition, mode)
}
private fun simplifyType(type: UnwrappedType): KotlinType {
@@ -72,4 +72,4 @@ internal class KtFe10PsiTypeProvider(override val analysisSession: KtFe10Analysi
val typeElement = ClsTypeElementImpl(context, typeText, '\u0000')
return typeElement.type
}
}
}