Commit 581f7e9
committed
Fix printing of OrderingConstraint
When printing a constraint, we print types which might
refer to type variables defined in the constraint, but the type printer
will rely on ctx.typerState.constraint to determine if these type
variables are instantiated, and this might be a different constraint
than the one we're trying to print, leading to an incorrect output.
This commit fixes this by temporarily setting ctx.typerState.constraint
to the current constraint when printing it, this required moving the
printing logic from OrderingConstraint to PlainPrinter.
At the same time, we drop the distinction between `toText` and
`contentsToString` (the former wrapped the printed output in
"Constraint(...)" and the latter didn't, now we never do) because
preserving it would have been complicated and it didn't seem worth it.
Also fix Ordering#toString to correctly print the bounds (the logic was
there but it was dead code).1 parent d71e8ef commit 581f7e9
File tree
5 files changed
+48
-46
lines changed- compiler/src/dotty/tools/dotc
- core
- printing
- typer
5 files changed
+48
-46
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | 186 | | |
Lines changed: 3 additions & 42 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
641 | 641 | | |
642 | 642 | | |
643 | 643 | | |
644 | | - | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
679 | | - | |
680 | | - | |
| 644 | + | |
681 | 645 | | |
682 | 646 | | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | | - | |
| 647 | + | |
687 | 648 | | |
688 | 649 | | |
689 | 650 | | |
| |||
692 | 653 | | |
693 | 654 | | |
694 | 655 | | |
695 | | - | |
| 656 | + | |
696 | 657 | | |
697 | 658 | | |
698 | 659 | | |
| |||
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
602 | 643 | | |
603 | 644 | | |
604 | 645 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
157 | 160 | | |
158 | 161 | | |
159 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
| 152 | + | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| |||
0 commit comments