Commit 7b9ccb4
committed
Add singleton string concatenation
This commit serves as a proof-of-concept of "overloaded" singleton ops.
`+` is already addition, so adding concatenation requires "overloading"
the `+` op. Scala does not support overloaded type aliases, so we must
have two + types in different objects. However:
- unqualified references (`+`) can be ambiguous (`int.+` or `string.+`)
- qualified types (e.g. `int.+`) cannot be used infix
The solution is to have a top-level `+` match type that redirects to
the qualified `int.+` or `string.+`. These are kept private, as an
implementation detail. The top-level match type is not considered as a
compiletime applied type, as we cannot do constant folding before the
match type has been applied.1 parent 5e287cd commit 7b9ccb4
File tree
4 files changed
+35
-4
lines changed- compiler/src/dotty/tools/dotc/core
- library/src/scala/compiletime/ops
- tests/neg
4 files changed
+35
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
903 | 903 | | |
904 | 904 | | |
905 | 905 | | |
906 | | - | |
| 906 | + | |
907 | 907 | | |
908 | 908 | | |
909 | 909 | | |
910 | 910 | | |
| 911 | + | |
| 912 | + | |
911 | 913 | | |
912 | 914 | | |
913 | 915 | | |
914 | | - | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
915 | 919 | | |
916 | 920 | | |
917 | 921 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3619 | 3619 | | |
3620 | 3620 | | |
3621 | 3621 | | |
| 3622 | + | |
| 3623 | + | |
| 3624 | + | |
| 3625 | + | |
| 3626 | + | |
3622 | 3627 | | |
3623 | 3628 | | |
3624 | 3629 | | |
| |||
3641 | 3646 | | |
3642 | 3647 | | |
3643 | 3648 | | |
3644 | | - | |
| 3649 | + | |
| 3650 | + | |
| 3651 | + | |
| 3652 | + | |
3645 | 3653 | | |
3646 | 3654 | | |
3647 | 3655 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
11 | 17 | | |
12 | 18 | | |
| |||
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
30 | 44 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
100 | 105 | | |
0 commit comments