Commit ff328ce
committed
Previously, whitebox inlines could be declared in three different ways
1. writing `inline def f <: T = ...` for inline methods
2. writing `inline given f: _ <: T` = ...` for inline givens
3. leaving out the result type for inline methods
The last was an oversight, not backed by the spec. It turned out that it
was not that easy to implement (3), so it was not done, and afterwards
code exploited the loophole.
In the new scheme, `whitebox` inlines demand `transparent`. The result type
can be given or left out, the effect is the same. The old `<:` result type
syntax will be phased out in a subseqent PR once the new syntax is in a release.
`transparent` is a soft modifier. It is valid only together with `inline`. Why not
allow `transparent` on its own and let it subsume `inline`. The point is that
we should steer users firmly towards blackbox macros, since they are much
easier to deal with for tooling. This means we want to make whitebox macros
strictly more verbose than blackbox macros. Otherwise someone might find
`transparent` "nicer" than `inline` and simply use it on these grounds without
realizing (or caring about) the consequences.
For the same reason I did not follow the (otherwise tempting) idea to simply
re-use `opaque` instead of `transparent`. An opaque inline kleeps its type on
expansion whereas a transparent one gets the type of its expansion. But that
would have nudged to user to prefer `inline` over `opaque inline`, so would
again have gjven the wrong incentive.
On the other hand, `transparent` as a dual of `opaque` is nice. It fits into
the same terminology. It's simply that type aliases are transparent by default
and have to be made opaque with a modifier, whereas inline methods are opaque
by default, and have to be made transparent by a modifier.
1 parent ad7da2f commit ff328ce
File tree
16 files changed
+72
-66
lines changed- compiler/src/dotty/tools/dotc
- ast
- core
- parsing
- printing
- typer
- docs/docs
- internals
- reference
- contextual
- metaprogramming
- tests
- explicit-nulls/pos
- neg
- pos
- run-macros/i7887
16 files changed
+72
-66
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
250 | | - | |
| 250 | + | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | 253 | | |
263 | 254 | | |
264 | 255 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
198 | 200 | | |
199 | 201 | | |
200 | 202 | | |
| |||
326 | 328 | | |
327 | 329 | | |
328 | 330 | | |
329 | | - | |
| 331 | + | |
330 | 332 | | |
331 | 333 | | |
332 | 334 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
| 596 | + | |
596 | 597 | | |
597 | 598 | | |
598 | 599 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2692 | 2692 | | |
2693 | 2693 | | |
2694 | 2694 | | |
| 2695 | + | |
2695 | 2696 | | |
2696 | 2697 | | |
2697 | 2698 | | |
| |||
2748 | 2749 | | |
2749 | 2750 | | |
2750 | 2751 | | |
2751 | | - | |
| 2752 | + | |
2752 | 2753 | | |
2753 | 2754 | | |
2754 | 2755 | | |
| |||
2766 | 2767 | | |
2767 | 2768 | | |
2768 | 2769 | | |
2769 | | - | |
| 2770 | + | |
| 2771 | + | |
| 2772 | + | |
| 2773 | + | |
| 2774 | + | |
2770 | 2775 | | |
2771 | 2776 | | |
2772 | 2777 | | |
| |||
3250 | 3255 | | |
3251 | 3256 | | |
3252 | 3257 | | |
3253 | | - | |
| 3258 | + | |
| 3259 | + | |
3254 | 3260 | | |
3255 | 3261 | | |
3256 | 3262 | | |
| |||
3521 | 3527 | | |
3522 | 3528 | | |
3523 | 3529 | | |
3524 | | - | |
| 3530 | + | |
| 3531 | + | |
3525 | 3532 | | |
3526 | 3533 | | |
3527 | 3534 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
285 | | - | |
| 285 | + | |
286 | 286 | | |
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
864 | 864 | | |
865 | 865 | | |
866 | 866 | | |
867 | | - | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
868 | 870 | | |
869 | 871 | | |
870 | 872 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
863 | 863 | | |
864 | 864 | | |
865 | 865 | | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
870 | 871 | | |
871 | 872 | | |
872 | 873 | | |
| |||
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
207 | 212 | | |
208 | 213 | | |
209 | 214 | | |
| |||
213 | 218 | | |
214 | 219 | | |
215 | 220 | | |
216 | | - | |
| 221 | + | |
217 | 222 | | |
218 | 223 | | |
219 | 224 | | |
| |||
223 | 228 | | |
224 | 229 | | |
225 | 230 | | |
226 | | - | |
| 231 | + | |
227 | 232 | | |
228 | 233 | | |
229 | 234 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1735 | 1735 | | |
1736 | 1736 | | |
1737 | 1737 | | |
| 1738 | + | |
1738 | 1739 | | |
1739 | 1740 | | |
1740 | | - | |
| 1741 | + | |
1741 | 1742 | | |
1742 | 1743 | | |
1743 | 1744 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
| 108 | + | |
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
| |||
0 commit comments