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: _posts/2024-12-05-release-notes-3.6.2.md
+11-5
Original file line number
Diff line number
Diff line change
@@ -80,18 +80,24 @@ This mechanism allows defining an abstract given instance that needs to be provi
80
80
81
81
```scala
82
82
traitOrder[T]
83
+
traitShow[T]
83
84
84
85
traitCollection:
85
86
// abstract member context-bound
86
87
typeElement:Order
87
-
88
-
classList[T:Order] extendsCollection:
88
+
// explicit abstract given
89
+
givenShow[Element] = compiletime.deferred
90
+
91
+
classList[T: {Order, Show}] extendsCollection:
89
92
typeElement=T
90
-
// given Order[Element] = ev$1 // generated by compiler, uses class context bound
91
-
92
-
classSet[T] extendsCollection:
93
+
// generated by compiler, uses class context bound
94
+
// override final given Order[Element] = evidence$1
95
+
// override final given Show[Element] = evidence$2
96
+
97
+
classSet[T:Showasshow] extendsCollection:
93
98
typeElement=T
94
99
overridegivenOrder[Element] =???// custom implementation provided by the user
100
+
// override final given Show[Element] = this.show // generated by compiler
95
101
```
96
102
97
103
See the updated [Contextual Abstractions](https://scala-lang.org/api/3.6.2/docs/docs/reference/contextual/givens.html) chapter of the Scala 3 reference guide to learn more about these changes.
0 commit comments