Rethink constraints incorporation

Namely, remove incorporation “otherInsideMyConstraint” to eliminate
constraint system redundancy and produce a potentially very large number
 of constructs.
Instead, introduce not so “spreadable” incorporation during variable
fixation (equality constraint with result type into other constraints).
^KT-41644 Fixed
^KT-42195 Fixed
^KT-42920 Fixed
^KT-42791 Fixed
^KT-41741 Fixed
This commit is contained in:
Victor Petukhov
2020-11-19 12:39:57 +03:00
parent 616e40f879
commit 0857b9c9e7
24 changed files with 299 additions and 136 deletions
@@ -0,0 +1,40 @@
// FIR_IDENTICAL
sealed class Tree<TIndex, out TCommon, out TInner, out TLeaf> {
abstract val value: TCommon
abstract val children: Map<TIndex, Tree<TIndex, TCommon, TInner, TLeaf>>
data class Inner<TIndex, TCommon, TInner, TLeaf>(
override val value: TCommon,
val innerValue: TInner,
override val children: Map<TIndex, Tree<TIndex, TCommon, TInner, TLeaf>>
) : Tree<TIndex, TCommon, TInner, TLeaf>()
data class Leaf<TIndex, TCommon, TLeaf>(
override val value: TCommon,
val leafValue: TLeaf
) : Tree<TIndex, TCommon, Nothing, TLeaf>() {
override val children: Map<TIndex, Tree<TIndex, TCommon, Nothing, TLeaf>> get() = emptyMap()
}
}
val tree = Tree.Inner(
"root",
Unit,
mapOf(
1 to Tree.Leaf("1", 1),
2 to Tree.Inner(
"2",
Unit,
mapOf(
1 to Tree.Leaf("21", 2),
2 to Tree.Inner(
"22",
Unit,
mapOf(1 to Tree.Leaf("221", 3))
),
3 to Tree.Leaf("23", 4)
)
)
)
)