FIR LC: fix nullable annotation on return type of suspend function
This commit is contained in:
committed by
Ilya Kirillov
parent
5880d80d26
commit
5aa8e2d0d1
+20
-10
@@ -54,13 +54,20 @@ internal class FirLightSimpleMethodForSymbol(
|
||||
_typeParameterList?.typeParameters ?: PsiTypeParameter.EMPTY_ARRAY
|
||||
|
||||
private fun computeAnnotations(isPrivate: Boolean): List<PsiAnnotation> {
|
||||
val nullability = if (isVoidReturnType || isPrivate) {
|
||||
val nullability = if (isPrivate) {
|
||||
NullabilityType.Unknown
|
||||
} else {
|
||||
analyzeWithSymbolAsContext(functionSymbol) {
|
||||
getTypeNullability(
|
||||
functionSymbol.annotatedType.type
|
||||
)
|
||||
analyzeWithSymbolAsContext(functionSymbol) l@{
|
||||
val ktType =
|
||||
when {
|
||||
functionSymbol.isSuspend -> // Any?
|
||||
return@l NullabilityType.Nullable
|
||||
isVoidReturnType ->
|
||||
return@l NullabilityType.Unknown
|
||||
else ->
|
||||
functionSymbol.annotatedType.type
|
||||
}
|
||||
getTypeNullability(ktType)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,13 +135,16 @@ internal class FirLightSimpleMethodForSymbol(
|
||||
}
|
||||
|
||||
private val _returnedType: PsiType by lazyPub {
|
||||
if (isVoidReturnType) return@lazyPub PsiType.VOID
|
||||
analyzeWithSymbolAsContext(functionSymbol) {
|
||||
val ktType =
|
||||
if (functionSymbol.isSuspend)
|
||||
analysisSession.builtinTypes.NULLABLE_ANY
|
||||
else
|
||||
functionSymbol.annotatedType.type
|
||||
when {
|
||||
functionSymbol.isSuspend -> // Any?
|
||||
analysisSession.builtinTypes.NULLABLE_ANY
|
||||
isVoidReturnType ->
|
||||
return@lazyPub PsiType.VOID
|
||||
else ->
|
||||
functionSymbol.annotatedType.type
|
||||
}
|
||||
ktType.asPsiType(this@FirLightSimpleMethodForSymbol)
|
||||
} ?: nonExistentType()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user