K2: expand return type properly in FirReturnTypeChecker

#KT-60229 Fixed
This commit is contained in:
Mikhail Glukhikh
2023-07-13 13:46:00 +02:00
committed by Space Team
parent 402e1de5fe
commit 51e8a72f47
3 changed files with 5 additions and 9 deletions
@@ -15,6 +15,8 @@ import org.jetbrains.kotlin.fir.declarations.FirFunction
import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.BlockExitNode
import org.jetbrains.kotlin.fir.resolve.dfa.controlFlowGraph
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
import org.jetbrains.kotlin.fir.types.coneType
import org.jetbrains.kotlin.fir.types.isNothing
import org.jetbrains.kotlin.fir.types.isUnit
@@ -32,7 +34,8 @@ object FirFunctionReturnChecker : FirFunctionChecker() {
if (declaration is FirPropertyAccessor && declaration.isSetter) return
if (declaration is FirConstructor) return
if (declaration is FirAnonymousFunction && declaration.isLambda) return
if (declaration.returnTypeRef.isUnit || declaration.returnTypeRef.isNothing) return
val returnType = declaration.returnTypeRef.coneType.fullyExpandedType(context.session)
if (returnType.isUnit || returnType.isNothing) return
val graph = declaration.controlFlowGraphReference?.controlFlowGraph ?: return
val blockExitNode = graph.exitNode.previousNodes.lastOrNull { it is BlockExitNode } ?: return
@@ -1,8 +0,0 @@
// ISSUE: KT-60299
private typealias T = Unit
internal fun x(): T {
val something = "OK"
something.hashCode()
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// ISSUE: KT-60299
private typealias T = Unit