FIR LC: use optimal type mapping mode for return type

This commit is contained in:
Jinseong Jeon
2021-11-04 00:17:01 -07:00
committed by Ilya Kirillov
parent d3c34fa200
commit 0da9ef873a
8 changed files with 43 additions and 8 deletions
@@ -34,10 +34,19 @@ internal class FirLightFieldForPropertySymbol(
when {
isDelegated ->
(kotlinOrigin as? KtProperty)?.delegateExpression?.let {
it.getKtType()?.asPsiType(this@FirLightFieldForPropertySymbol)
val ktType = it.getKtType()
ktType?.asPsiType(
this@FirLightFieldForPropertySymbol,
ktType.getOptimalModeForReturnType(containingClass.isAnnotationType)
)
}
else ->
propertySymbol.annotatedType.type.asPsiType(this@FirLightFieldForPropertySymbol)
else -> {
val ktType = propertySymbol.annotatedType.type
ktType.asPsiType(
this@FirLightFieldForPropertySymbol,
ktType.getOptimalModeForReturnType(containingClass.isAnnotationType)
)
}
}
} ?: nonExistentType()
}
@@ -150,9 +150,12 @@ internal class FirLightAccessorMethodForSymbol(
private val _returnedType: PsiType by lazyPub {
if (!isGetter) return@lazyPub PsiType.VOID
analyzeWithSymbolAsContext(containingPropertySymbol) {
containingPropertySymbol.annotatedType.type.asPsiType(this@FirLightAccessorMethodForSymbol)
?: this@FirLightAccessorMethodForSymbol.nonExistentType()
}
val ktType = containingPropertySymbol.annotatedType.type
ktType.asPsiType(
this@FirLightAccessorMethodForSymbol,
ktType.getOptimalModeForReturnType(containingClass.isAnnotationType)
)
} ?: nonExistentType()
}
override fun getReturnType(): PsiType = _returnedType
@@ -145,7 +145,10 @@ internal class FirLightSimpleMethodForSymbol(
else ->
functionSymbol.annotatedType.type
}
ktType.asPsiType(this@FirLightSimpleMethodForSymbol)
ktType.asPsiType(
this@FirLightSimpleMethodForSymbol,
ktType.getOptimalModeForReturnType(containingClass.isAnnotationType)
)
} ?: nonExistentType()
}