Commit 6db9976
committed
For switch-Matches in PatMap, convert scrutinee and alternatives to Int.
In JVM bytecode as well in Scala.js IR, switches only work with
primitive ints. Therefore, it makes more sense to convert the
scrutinee and alternatives of switch-Matches to Ints early.
This is also what scalac does. See `RegularSwitchMaker` in
`patmat/MatchOptimization.scala`.
The JVM back-end tolerates non-ints due its aggressive and blind
adaptations everywhere (not because of a deliberate action to
support non-Ints). However, the Scala.js back-end does not like
receiving non-Ints in `Match`es, because it is much more
conservative in where it inserts adaptations (i.e., almost
nowhere).1 parent d6d374a commit 6db9976
File tree
1 file changed
+23
-9
lines changed- compiler/src/dotty/tools/dotc/transform
1 file changed
+23
-9
lines changedLines changed: 23 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
821 | 821 | | |
822 | 822 | | |
823 | 823 | | |
824 | | - | |
825 | | - | |
826 | | - | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
827 | 840 | | |
828 | | - | |
| 841 | + | |
829 | 842 | | |
830 | | - | |
| 843 | + | |
831 | 844 | | |
832 | | - | |
833 | | - | |
834 | | - | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
835 | 849 | | |
836 | 850 | | |
837 | 851 | | |
| |||
892 | 906 | | |
893 | 907 | | |
894 | 908 | | |
895 | | - | |
| 909 | + | |
896 | 910 | | |
897 | 911 | | |
898 | 912 | | |
| |||
0 commit comments