KT-61728 [LL API] Ignore CFG nodes with uninitialized flow
This is done until the KT-61794 is fixed
This commit is contained in:
committed by
Space Team
parent
23363ef1bd
commit
a20dea1b0a
+8
-2
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.fir.resolve.dfa.PropertyStability
|
|||||||
import org.jetbrains.kotlin.fir.resolve.dfa.RealVariable
|
import org.jetbrains.kotlin.fir.resolve.dfa.RealVariable
|
||||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.CFGNode
|
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.CFGNode
|
||||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.ClassExitNode
|
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.ClassExitNode
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.MergePostponedLambdaExitsNode
|
||||||
import org.jetbrains.kotlin.fir.resolve.dfa.controlFlowGraph
|
import org.jetbrains.kotlin.fir.resolve.dfa.controlFlowGraph
|
||||||
import org.jetbrains.kotlin.fir.resolve.dfa.smartCastedType
|
import org.jetbrains.kotlin.fir.resolve.dfa.smartCastedType
|
||||||
import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculatorForFullBodyResolve
|
import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculatorForFullBodyResolve
|
||||||
@@ -283,8 +284,13 @@ private class ContextCollectorVisitor(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isAcceptedControlFlowNode(node: CFGNode<*>): Boolean {
|
private fun isAcceptedControlFlowNode(node: CFGNode<*>): Boolean = when {
|
||||||
return node !is ClassExitNode
|
node is ClassExitNode -> false
|
||||||
|
|
||||||
|
// TODO Remove as soon as KT-61728 is fixed
|
||||||
|
node is MergePostponedLambdaExitsNode && !node.flowInitialized -> false
|
||||||
|
|
||||||
|
else -> true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitScript(script: FirScript) {
|
override fun visitScript(script: FirScript) {
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun foo(param: String?): String? {
|
||||||
|
val tmp = param?.let {
|
||||||
|
<expr>it</expr>
|
||||||
|
} ?: return null
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
Tower Data Context:
|
||||||
|
Element 0
|
||||||
|
Scope: FirDefaultStarImportingScope
|
||||||
|
Element 1
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 2
|
||||||
|
Scope: FirExplicitStarImportingScope
|
||||||
|
Element 3
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 4
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 5
|
||||||
|
Scope: FirPackageMemberScope
|
||||||
|
Element 6
|
||||||
|
Scope: FirExplicitSimpleImportingScope
|
||||||
|
Element 7
|
||||||
|
Scope: FirLocalScope
|
||||||
|
Properties:
|
||||||
|
FirValueParameterSymbol param: R|kotlin/String?|
|
||||||
|
Element 8
|
||||||
|
Scope: FirLocalScope
|
||||||
|
Element 9
|
||||||
|
Scope: FirLocalScope
|
||||||
|
Properties:
|
||||||
|
FirValueParameterSymbol it: R|kotlin/String|
|
||||||
|
Element 10
|
||||||
|
Scope: FirLocalScope
|
||||||
|
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] KT-61728.kt
|
||||||
|
public final [ResolvedTo(BODY_RESOLVE)] fun foo([ResolvedTo(BODY_RESOLVE)] param: R|kotlin/String?|): R|kotlin/String?| {
|
||||||
|
[ResolvedTo(BODY_RESOLVE)] lval tmp: R|kotlin/String| = R|<local>/param|?.{ $subj$.R|kotlin/let|<R|kotlin/String|, R|kotlin/String|>(<L> = [ResolvedTo(BODY_RESOLVE)] let@fun <anonymous>([ResolvedTo(BODY_RESOLVE)] it: R|kotlin/String|): R|kotlin/String| <inline=Inline, kind=EXACTLY_ONCE> {
|
||||||
|
^ R|<local>/it|
|
||||||
|
}
|
||||||
|
) } ?: ^foo Null(null)
|
||||||
|
}
|
||||||
+6
@@ -66,6 +66,12 @@ public class ContextCollectorSourceTestGenerated extends AbstractContextCollecto
|
|||||||
runTest("analysis/low-level-api-fir/testdata/contextCollector/innerClasses.kt");
|
runTest("analysis/low-level-api-fir/testdata/contextCollector/innerClasses.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("KT-61728.kt")
|
||||||
|
public void testKT_61728() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testdata/contextCollector/KT-61728.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lambdaArguments.kt")
|
@TestMetadata("lambdaArguments.kt")
|
||||||
public void testLambdaArguments() throws Exception {
|
public void testLambdaArguments() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user