Commit dca3ea1
committed
Fix inconsistent typeSize for TupleN vs nested pairs
Previously, `typeSize` reported different values for standard `TupleN`
types (e.g., `(A, B)`) compared to their equivalent recursive pair
encodings (e.g., `A *: B *: EmptyTuple`). This discrepancy occurred
because `TupleN` is a flat `AppliedType`, while the nested encoding
forms a deeper tree structure.
This patch modifies `TypeSizeAccumulator` to canonicalize `TupleN`
types into their recursive `*:` representation before calculating
the size. This ensures that the size metric is consistent regardless
of whether the tuple is represented syntactically or structurally.
This change is verified by a new unit test in `TypesTest`, which
confirms that both `Tuple3[Int, Boolean, Double]` and its recursive
equivalent `Int *: Boolean *: Double *: EmptyTuple` now yield
identical `typeSize` values.
Fixes #247301 parent 96be092 commit dca3ea1
File tree
3 files changed
+29
-3
lines changed- compiler
- src/dotty/tools/dotc/core
- test/dotty/tools/dotc
- core
- typer
3 files changed
+29
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7124 | 7124 | | |
7125 | 7125 | | |
7126 | 7126 | | |
7127 | | - | |
| 7127 | + | |
| 7128 | + | |
| 7129 | + | |
| 7130 | + | |
| 7131 | + | |
| 7132 | + | |
| 7133 | + | |
| 7134 | + | |
| 7135 | + | |
7128 | 7136 | | |
7129 | 7137 | | |
7130 | 7138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
| 53 | + | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
0 commit comments