diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/safeCallOnTypeAlias.fir.txt b/compiler/fir/analysis-tests/testData/resolve/callResolution/safeCallOnTypeAlias.fir.txt index 23cb5301cc6..0e2211cd68c 100644 --- a/compiler/fir/analysis-tests/testData/resolve/callResolution/safeCallOnTypeAlias.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/safeCallOnTypeAlias.fir.txt @@ -1,7 +1,7 @@ FILE: safeCallOnTypeAlias.kt public final typealias MyTypeAlias = R|() -> kotlin/String?| public final fun foo(x: R|MyTypeAlias|): R|kotlin/Unit| { - R|/x|?.{ $subj$.R|kotlin/let| kotlin/String?|, R|kotlin/String|>( = let@fun (y: R|() -> kotlin/String?|): R|kotlin/String| { + R|/x|?.{ $subj$.R|kotlin/let| kotlin/String?|, R|kotlin/String?|>( = let@fun (y: R|() -> kotlin/String?|): R|kotlin/String?| { ^ R|/y|.R|SubstitutionOverride|()?.{ $subj$.R|kotlin/let|( = let@fun (result: R|kotlin/String|): R|kotlin/String| { ^ R|/bar|(R|/result|) } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/coercionToUnitWithEarlyReturn.fir.txt b/compiler/fir/analysis-tests/testData/resolve/inference/coercionToUnitWithEarlyReturn.fir.txt index e04a089fcf3..a819ba09632 100644 --- a/compiler/fir/analysis-tests/testData/resolve/inference/coercionToUnitWithEarlyReturn.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/inference/coercionToUnitWithEarlyReturn.fir.txt @@ -11,7 +11,7 @@ FILE: coercionToUnitWithEarlyReturn.kt public final fun foo(x: R|() -> kotlin/Unit|): R|kotlin/Unit| { } public final fun main(x: R|A?|): R|kotlin/Unit| { - lval lambda: R|() -> kotlin/Unit| = l@fun (): R|kotlin/Unit| { + lval lambda: R|() -> kotlin/Unit?| = l@fun (): R|kotlin/Unit?| { when () { ==(R|/x|?.{ $subj$.R|kotlin/Any.hashCode|() }, Int(0)) -> { ^@l Unit @@ -21,5 +21,5 @@ FILE: coercionToUnitWithEarlyReturn.kt ^ R|/x|?.{ $subj$.R|/A.unit|() } } - R|/foo|(R|/lambda|) + #(R|/lambda|) } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/coercionToUnitWithEarlyReturn.kt b/compiler/fir/analysis-tests/testData/resolve/inference/coercionToUnitWithEarlyReturn.kt index 1739ea41199..575ef2a0fe7 100644 --- a/compiler/fir/analysis-tests/testData/resolve/inference/coercionToUnitWithEarlyReturn.kt +++ b/compiler/fir/analysis-tests/testData/resolve/inference/coercionToUnitWithEarlyReturn.kt @@ -15,5 +15,5 @@ fun main(x: A?) { } // lambda has a type (() -> Unit?) - foo(lambda) + foo(lambda) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt index 3a3e2ac5653..8bb8403593d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt @@ -133,7 +133,6 @@ class ControlFlowGraphBuilder { fun CFGNode<*>.extractArgument(): FirElement? = when (this) { is FunctionEnterNode, is TryMainBlockEnterNode, is CatchClauseEnterNode -> null - is ExitSafeCallNode -> lastPreviousNode.extractArgument() is StubNode, is BlockExitNode -> firstPreviousNode.extractArgument() else -> fir.extractArgument() } @@ -1090,8 +1089,9 @@ class ControlFlowGraphBuilder { * lastNode -> exitNode * instead of * lastNode -> enterNode -> exitNode - * because of we need to fork flow on `enterNode`, so `exitNode` + * because we need to fork flow before `enterNode`, so `exitNode` * will have unchanged flow from `lastNode` + * which corresponds to a path with nullable receiver. */ val lastNode = lastNodes.pop() val enterNode = createEnterSafeCallNode(safeCall) @@ -1104,6 +1104,12 @@ class ControlFlowGraphBuilder { } fun exitSafeCall(): ExitSafeCallNode { + // There will be two paths towards this exit safe call node: + // one from the node prior to the enclosing safe call, and + // the other from the selector part in the enclosing safe call. + // Note that *neither* points to the safe call directly. + // So, when it comes to the real exit of the enclosing block/function, + // the safe call bound to this exit safe call node should be retrieved. return exitSafeCallNodes.pop().also { addNewSimpleNode(it) it.updateDeadStatus() diff --git a/compiler/testData/diagnostics/testsWithStdLib/buildLazyValueForMap.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/buildLazyValueForMap.fir.kt deleted file mode 100644 index d2698163573..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/buildLazyValueForMap.fir.kt +++ /dev/null @@ -1,23 +0,0 @@ -// !WITH_NEW_INFERENCE - -interface ClassId - -interface JavaAnnotation { - val classId: ClassId? -} - -interface JavaAnnotationOwner { - val annotations: Collection -} - -interface MapBasedJavaAnnotationOwner : JavaAnnotationOwner { - val annotationsByFqNameHash: Map -} - -fun JavaAnnotationOwner.buildLazyValueForMap() = lazy { - annotations.associateBy { it.classId?.hashCode() } -} - -abstract class BinaryJavaMethodBase(): MapBasedJavaAnnotationOwner { - override val annotationsByFqNameHash by buildLazyValueForMap() -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/buildLazyValueForMap.kt b/compiler/testData/diagnostics/testsWithStdLib/buildLazyValueForMap.kt index 607e23aabb0..be566e49c07 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/buildLazyValueForMap.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/buildLazyValueForMap.kt @@ -1,3 +1,5 @@ +// FIR_IDENTICAL + interface ClassId interface JavaAnnotation {