FIR DFA: workaround KT-46826

This commit is contained in:
Tianyu Geng
2021-05-19 16:29:20 -07:00
committed by TeamCityServer
parent 0ecc752813
commit b78b50e1f8
2 changed files with 5 additions and 15 deletions
@@ -134,7 +134,7 @@ abstract class PersistentLogicSystem(context: ConeInferenceContext) : LogicSyste
val variables = flows.flatMap { it.approvedTypeStatements.keys }.toSet()
for (variable in variables) {
val info = mergeOperation(flows.map { it.getApprovedTypeStatements(variable, commonFlow) }) ?: continue
val info = mergeOperation(flows.map { it.getApprovedTypeStatements(variable) }) ?: continue
removeTypeStatementsAboutVariable(commonFlow, variable)
val thereWereReassignments = variable.hasDifferentReassignments(flows)
if (thereWereReassignments) {
@@ -210,23 +210,13 @@ abstract class PersistentLogicSystem(context: ConeInferenceContext) : LogicSyste
}
@OptIn(DfaInternals::class)
private fun PersistentFlow.getApprovedTypeStatements(variable: RealVariable, parentFlow: PersistentFlow): MutableTypeStatement {
private fun PersistentFlow.getApprovedTypeStatements(variable: RealVariable): MutableTypeStatement {
var flow = this
val result = MutableTypeStatement(variable)
val variableUnderAlias = directAliasMap[variable]
if (variableUnderAlias == null) {
// get approved type statement even though the starting flow == parent flow
if (flow == parentFlow) {
flow.approvedTypeStatements[variable]?.let {
result += it
}
} else {
while (flow != parentFlow) {
flow.approvedTypeStatements[variable]?.let {
result += it
}
flow = flow.previousFlow!!
}
flow.approvedTypeStatements[variable]?.let {
result += it
}
} else {
result.exactType.addIfNotNull(variableUnderAlias.originalType)