K2: expand return type properly in FirReturnTypeChecker
#KT-60229 Fixed
This commit is contained in:
committed by
Space Team
parent
402e1de5fe
commit
51e8a72f47
+4
-1
@@ -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
|
||||
|
||||
-8
@@ -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
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-60299
|
||||
|
||||
private typealias T = Unit
|
||||
|
||||
Reference in New Issue
Block a user