FIR DFA: deprioritize branches with no reassignments in flow unions

callBothLambdas({ x = "..." }, { x is Int })
  // the assignment always executes, so x is String | (String & Int);
  // the latter is always a subtype of the former so it can be ignored
This commit is contained in:
pyos
2022-11-07 15:18:46 +01:00
committed by teamcity
parent fd609416c6
commit 3436535e7a
5 changed files with 442 additions and 314 deletions
@@ -61,8 +61,8 @@ FILE: flowFromTwoInplaceLambdas.kt
^ Int(123)
}
)
R|<local>/p|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
R|<local>/p|?.{ $subj$.R|kotlin/String.length| }
R|<local>/p|.<Unresolved name: length>#
R|<local>/p|?.{ $subj$.<Unresolved name: length># }
}
public final fun test3(x: R|kotlin/Any?|): R|kotlin/Unit| {
lvar p: R|kotlin/Any?| = R|<local>/x|
@@ -106,3 +106,18 @@ FILE: flowFromTwoInplaceLambdas.kt
R|<local>/x|.R|/I1.x|
R|<local>/x|.R|/I2.y|
}
public final fun test5(x: R|kotlin/Any?|, q: R|kotlin/String?|): R|kotlin/Unit| {
lvar p: R|kotlin/Any?| = R|<local>/x|
R|<local>/p|.<Unresolved name: length>#
R|/run2|<R|kotlin/Int?|>(run2@fun <anonymous>(): R|kotlin/Int?| <inline=NoInline, kind=EXACTLY_ONCE> {
(R|<local>/p| as R|kotlin/Int|)
^ Int(123)
}
, run2@fun <anonymous>(): R|kotlin/Int?| <inline=NoInline, kind=EXACTLY_ONCE> {
R|<local>/p| = R|<local>/q|
^ R|/n|<R|kotlin/Int?|>()
}
)
R|<local>/p|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
R|<local>/p|?.{ $subj$.R|kotlin/String.length| }
}