diff --git a/analysis/symbol-light-classes/src/org/jetbrains/kotlin/light/classes/symbol/methods/FirLightSimpleMethodForSymbol.kt b/analysis/symbol-light-classes/src/org/jetbrains/kotlin/light/classes/symbol/methods/FirLightSimpleMethodForSymbol.kt index cdcffcfaac9..9a219f372b4 100644 --- a/analysis/symbol-light-classes/src/org/jetbrains/kotlin/light/classes/symbol/methods/FirLightSimpleMethodForSymbol.kt +++ b/analysis/symbol-light-classes/src/org/jetbrains/kotlin/light/classes/symbol/methods/FirLightSimpleMethodForSymbol.kt @@ -54,13 +54,20 @@ internal class FirLightSimpleMethodForSymbol( _typeParameterList?.typeParameters ?: PsiTypeParameter.EMPTY_ARRAY private fun computeAnnotations(isPrivate: Boolean): List { - 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() } diff --git a/compiler/testData/asJava/ultraLightClasses/coroutines.java b/compiler/testData/asJava/ultraLightClasses/coroutines.java index d45451433ac..cbcc9b1e094 100644 --- a/compiler/testData/asJava/ultraLightClasses/coroutines.java +++ b/compiler/testData/asJava/ultraLightClasses/coroutines.java @@ -7,6 +7,8 @@ public final class Foo /* Foo*/ { } public final class Boo /* Boo*/ { + private final java.lang.Object doSomething(Foo, kotlin.coroutines.Continuation);// doSomething(Foo, kotlin.coroutines.Continuation) + public Boo();// .ctor() } @@ -30,4 +32,4 @@ public final class Derived /* Derived*/ implements Base { public Derived();// .ctor() -} \ No newline at end of file +} diff --git a/compiler/testData/asJava/ultraLightClasses/coroutines.kt b/compiler/testData/asJava/ultraLightClasses/coroutines.kt index b3da0b5e423..77cbdf08754 100644 --- a/compiler/testData/asJava/ultraLightClasses/coroutines.kt +++ b/compiler/testData/asJava/ultraLightClasses/coroutines.kt @@ -1,4 +1,5 @@ //RELEASE_COROUTINE_NEEDED +//CHECK_BY_JAVA_FILE class Foo { suspend fun doSomething(foo: Foo): Bar {} } @@ -18,3 +19,5 @@ interface Base { class Derived: Base { override suspend fun foo() { ... } } + +// FIR_COMPARISON diff --git a/compiler/testData/asJava/ultraLightFacades/coroutines.kt b/compiler/testData/asJava/ultraLightFacades/coroutines.kt index 4e449475b24..02d140d97f4 100644 --- a/compiler/testData/asJava/ultraLightFacades/coroutines.kt +++ b/compiler/testData/asJava/ultraLightFacades/coroutines.kt @@ -1,4 +1,6 @@ //RELEASE_COROUTINE_NEEDED suspend fun doSomething(foo: String): Int {} -fun async(block: suspend () -> T) \ No newline at end of file +fun async(block: suspend () -> T) + +// FIR_COMPARISON