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> {
|
protected fun <E> Collection<Collection<E>>.intersectSets(): Set<E> {
|
||||||
if (isEmpty()) return emptySet()
|
if (isEmpty()) return emptySet()
|
||||||
val iterator = iterator()
|
val iterator = iterator()
|
||||||
val result = HashSet<E>(iterator.next())
|
val result = LinkedHashSet<E>(iterator.next())
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
result.retainAll(iterator.next())
|
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.FirElement
|
||||||
import org.jetbrains.kotlin.fir.declarations.modality
|
import org.jetbrains.kotlin.fir.declarations.modality
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
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.AbstractFirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||||
@@ -143,13 +142,13 @@ abstract class TypeStatement : Statement<TypeStatement>() {
|
|||||||
|
|
||||||
class MutableTypeStatement(
|
class MutableTypeStatement(
|
||||||
override val variable: RealVariable,
|
override val variable: RealVariable,
|
||||||
override val exactType: MutableSet<ConeKotlinType> = HashSet(),
|
override val exactType: MutableSet<ConeKotlinType> = linkedSetOf(),
|
||||||
override val exactNotType: MutableSet<ConeKotlinType> = HashSet()
|
override val exactNotType: MutableSet<ConeKotlinType> = linkedSetOf()
|
||||||
) : TypeStatement() {
|
) : TypeStatement() {
|
||||||
override fun plus(other: TypeStatement): MutableTypeStatement = MutableTypeStatement(
|
override fun plus(other: TypeStatement): MutableTypeStatement = MutableTypeStatement(
|
||||||
variable,
|
variable,
|
||||||
HashSet(exactType).apply { addAll(other.exactType) },
|
LinkedHashSet(exactType).apply { addAll(other.exactType) },
|
||||||
HashSet(exactNotType).apply { addAll(other.exactNotType) }
|
LinkedHashSet(exactNotType).apply { addAll(other.exactNotType) }
|
||||||
)
|
)
|
||||||
|
|
||||||
override val isEmpty: Boolean
|
override val isEmpty: Boolean
|
||||||
@@ -158,8 +157,8 @@ class MutableTypeStatement(
|
|||||||
override fun invert(): TypeStatement {
|
override fun invert(): TypeStatement {
|
||||||
return MutableTypeStatement(
|
return MutableTypeStatement(
|
||||||
variable,
|
variable,
|
||||||
HashSet(exactNotType),
|
LinkedHashSet(exactNotType),
|
||||||
HashSet(exactType)
|
LinkedHashSet(exactType)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +167,7 @@ class MutableTypeStatement(
|
|||||||
exactNotType += info.exactNotType
|
exactNotType += info.exactNotType
|
||||||
}
|
}
|
||||||
|
|
||||||
fun copy(): MutableTypeStatement = MutableTypeStatement(variable, HashSet(exactType), HashSet(exactNotType))
|
fun copy(): MutableTypeStatement = MutableTypeStatement(variable, LinkedHashSet(exactType), LinkedHashSet(exactNotType))
|
||||||
}
|
}
|
||||||
|
|
||||||
class Implication(
|
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 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 =
|
infix fun RealVariable.typeEq(type: ConeKotlinType): TypeStatement =
|
||||||
if (type !is ConeClassErrorType) {
|
if (type !is ConeClassErrorType) {
|
||||||
MutableTypeStatement(this, HashSet<ConeKotlinType>().apply { this += type }, HashSet())
|
MutableTypeStatement(this, linkedSetOf<ConeKotlinType>().apply { this += type }, HashSet())
|
||||||
} else {
|
} else {
|
||||||
MutableTypeStatement(this)
|
MutableTypeStatement(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
infix fun RealVariable.typeNotEq(types: MutableSet<ConeKotlinType>): TypeStatement = MutableTypeStatement(this, HashSet(), types)
|
|
||||||
infix fun RealVariable.typeNotEq(type: ConeKotlinType): TypeStatement =
|
infix fun RealVariable.typeNotEq(type: ConeKotlinType): TypeStatement =
|
||||||
if (type !is ConeClassErrorType) {
|
if (type !is ConeClassErrorType) {
|
||||||
MutableTypeStatement(this, HashSet(), HashSet<ConeKotlinType>().apply { this += type })
|
MutableTypeStatement(this, linkedSetOf(), LinkedHashSet<ConeKotlinType>().apply { this += type })
|
||||||
} else {
|
} else {
|
||||||
MutableTypeStatement(this)
|
MutableTypeStatement(this)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user