FIR DFA: stabilize type order
This commit is contained in:
@@ -115,7 +115,7 @@ abstract class LogicSystem<FLOW : Flow>(protected val context: ConeInferenceCont
|
||||
protected fun <E> Collection<Collection<E>>.intersectSets(): Set<E> {
|
||||
if (isEmpty()) return emptySet()
|
||||
val iterator = iterator()
|
||||
val result = HashSet<E>(iterator.next())
|
||||
val result = LinkedHashSet<E>(iterator.next())
|
||||
while (iterator.hasNext()) {
|
||||
result.retainAll(iterator.next())
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.declarations.modality
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.Operation
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
@@ -143,13 +142,13 @@ abstract class TypeStatement : Statement<TypeStatement>() {
|
||||
|
||||
class MutableTypeStatement(
|
||||
override val variable: RealVariable,
|
||||
override val exactType: MutableSet<ConeKotlinType> = HashSet(),
|
||||
override val exactNotType: MutableSet<ConeKotlinType> = HashSet()
|
||||
override val exactType: MutableSet<ConeKotlinType> = linkedSetOf(),
|
||||
override val exactNotType: MutableSet<ConeKotlinType> = linkedSetOf()
|
||||
) : TypeStatement() {
|
||||
override fun plus(other: TypeStatement): MutableTypeStatement = MutableTypeStatement(
|
||||
variable,
|
||||
HashSet(exactType).apply { addAll(other.exactType) },
|
||||
HashSet(exactNotType).apply { addAll(other.exactNotType) }
|
||||
LinkedHashSet(exactType).apply { addAll(other.exactType) },
|
||||
LinkedHashSet(exactNotType).apply { addAll(other.exactNotType) }
|
||||
)
|
||||
|
||||
override val isEmpty: Boolean
|
||||
@@ -158,8 +157,8 @@ class MutableTypeStatement(
|
||||
override fun invert(): TypeStatement {
|
||||
return MutableTypeStatement(
|
||||
variable,
|
||||
HashSet(exactNotType),
|
||||
HashSet(exactType)
|
||||
LinkedHashSet(exactNotType),
|
||||
LinkedHashSet(exactType)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -168,7 +167,7 @@ class MutableTypeStatement(
|
||||
exactNotType += info.exactNotType
|
||||
}
|
||||
|
||||
fun copy(): MutableTypeStatement = MutableTypeStatement(variable, HashSet(exactType), HashSet(exactNotType))
|
||||
fun copy(): MutableTypeStatement = MutableTypeStatement(variable, LinkedHashSet(exactType), LinkedHashSet(exactNotType))
|
||||
}
|
||||
|
||||
class Implication(
|
||||
@@ -209,18 +208,16 @@ infix fun DataFlowVariable.notEq(constant: Boolean?): OperationStatement {
|
||||
|
||||
infix fun OperationStatement.implies(effect: Statement<*>): Implication = Implication(this, effect)
|
||||
|
||||
infix fun RealVariable.typeEq(types: MutableSet<ConeKotlinType>): TypeStatement = MutableTypeStatement(this, types, HashSet())
|
||||
infix fun RealVariable.typeEq(type: ConeKotlinType): TypeStatement =
|
||||
if (type !is ConeClassErrorType) {
|
||||
MutableTypeStatement(this, HashSet<ConeKotlinType>().apply { this += type }, HashSet())
|
||||
MutableTypeStatement(this, linkedSetOf<ConeKotlinType>().apply { this += type }, HashSet())
|
||||
} else {
|
||||
MutableTypeStatement(this)
|
||||
}
|
||||
|
||||
infix fun RealVariable.typeNotEq(types: MutableSet<ConeKotlinType>): TypeStatement = MutableTypeStatement(this, HashSet(), types)
|
||||
infix fun RealVariable.typeNotEq(type: ConeKotlinType): TypeStatement =
|
||||
if (type !is ConeClassErrorType) {
|
||||
MutableTypeStatement(this, HashSet(), HashSet<ConeKotlinType>().apply { this += type })
|
||||
MutableTypeStatement(this, linkedSetOf(), LinkedHashSet<ConeKotlinType>().apply { this += type })
|
||||
} else {
|
||||
MutableTypeStatement(this)
|
||||
}
|
||||
Reference in New Issue
Block a user