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
|
_typeParameterList?.typeParameters ?: PsiTypeParameter.EMPTY_ARRAY
|
||||||
|
|
||||||
private fun computeAnnotations(isPrivate: Boolean): List<PsiAnnotation> {
|
private fun computeAnnotations(isPrivate: Boolean): List<PsiAnnotation> {
|
||||||
val nullability = if (isVoidReturnType || isPrivate) {
|
val nullability = if (isPrivate) {
|
||||||
NullabilityType.Unknown
|
NullabilityType.Unknown
|
||||||
} else {
|
} else {
|
||||||
analyzeWithSymbolAsContext(functionSymbol) {
|
analyzeWithSymbolAsContext(functionSymbol) l@{
|
||||||
getTypeNullability(
|
val ktType =
|
||||||
functionSymbol.annotatedType.type
|
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 {
|
private val _returnedType: PsiType by lazyPub {
|
||||||
if (isVoidReturnType) return@lazyPub PsiType.VOID
|
|
||||||
analyzeWithSymbolAsContext(functionSymbol) {
|
analyzeWithSymbolAsContext(functionSymbol) {
|
||||||
val ktType =
|
val ktType =
|
||||||
if (functionSymbol.isSuspend)
|
when {
|
||||||
analysisSession.builtinTypes.NULLABLE_ANY
|
functionSymbol.isSuspend -> // Any?
|
||||||
else
|
analysisSession.builtinTypes.NULLABLE_ANY
|
||||||
functionSymbol.annotatedType.type
|
isVoidReturnType ->
|
||||||
|
return@lazyPub PsiType.VOID
|
||||||
|
else ->
|
||||||
|
functionSymbol.annotatedType.type
|
||||||
|
}
|
||||||
ktType.asPsiType(this@FirLightSimpleMethodForSymbol)
|
ktType.asPsiType(this@FirLightSimpleMethodForSymbol)
|
||||||
} ?: nonExistentType()
|
} ?: nonExistentType()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ public final class Foo /* Foo*/ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class Boo /* Boo*/ {
|
public final class Boo /* Boo*/ {
|
||||||
|
private final java.lang.Object doSomething(Foo, kotlin.coroutines.Continuation<? super Bar>);// doSomething(Foo, kotlin.coroutines.Continuation<? super Bar>)
|
||||||
|
|
||||||
public Boo();// .ctor()
|
public Boo();// .ctor()
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -30,4 +32,4 @@ public final class Derived /* Derived*/ implements Base {
|
|||||||
|
|
||||||
public Derived();// .ctor()
|
public Derived();// .ctor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
//RELEASE_COROUTINE_NEEDED
|
//RELEASE_COROUTINE_NEEDED
|
||||||
|
//CHECK_BY_JAVA_FILE
|
||||||
class Foo {
|
class Foo {
|
||||||
suspend fun doSomething(foo: Foo): Bar {}
|
suspend fun doSomething(foo: Foo): Bar {}
|
||||||
}
|
}
|
||||||
@@ -18,3 +19,5 @@ interface Base {
|
|||||||
class Derived: Base {
|
class Derived: Base {
|
||||||
override suspend fun foo() { ... }
|
override suspend fun foo() { ... }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIR_COMPARISON
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
//RELEASE_COROUTINE_NEEDED
|
//RELEASE_COROUTINE_NEEDED
|
||||||
suspend fun doSomething(foo: String): Int {}
|
suspend fun doSomething(foo: String): Int {}
|
||||||
|
|
||||||
fun <T> async(block: suspend () -> T)
|
fun <T> async(block: suspend () -> T)
|
||||||
|
|
||||||
|
// FIR_COMPARISON
|
||||||
|
|||||||
Reference in New Issue
Block a user