You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/blog/_posts/2019-11-04-20th-dotty-milestone-release.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,12 +96,15 @@ It is now possible to specialize `inline given`s with the help of `<:` as follow
96
96
traitA
97
97
classBextendsA
98
98
99
-
inlinegiventc<:A=B()
99
+
inlinegivenwbas_<:A=B()
100
100
101
101
valx:B= summon[A]
102
102
```
103
-
104
-
This change brings `given`s even with the ordinary `inline def`s.
103
+
In this example, the inline given `wb` will return a result of a subtype of the declared upper bound `A` as determined by `B`. In our terminology, `wb` is a whitebox macro. Contrast with the following definition of a blackbox given macro `bb`:
104
+
```
105
+
inline given bb as A = B()
106
+
```
107
+
Here, the type of `bb` will always be `A`, no matter what `B` returns.
105
108
106
109
## Normal parameters can follow `given` parameters
107
110
Previously normal parameters after `given` parameter was disallowed mainly because they looked awkward with the old syntax. With the syntax being improved, this restriction is now lifted and you can write, e.g., the following program:
0 commit comments