Skip to content

Commit 024f828

Browse files
committed
Discuss how to suppress the warning
1 parent 41a85c9 commit 024f828

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

_posts/2024-08-01-given-priority-change-3.5.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,35 @@ useful to verify that implicit search results will not be ambiguous in
117117
future versions or to test your application at runtime with the new
118118
rules in effect.
119119

120+
#### Suppressing Warnings
121+
122+
If you need to suppress the new warning related to changes in `given`
123+
search preference, you can use Scala’s facilities for configuring
124+
warnings. For example, you can suppress the warning globally via the
125+
command line:
126+
127+
```bash
128+
scalac file.scala "-Wconf:msg=Given search preference:s"
129+
```
130+
131+
It is also possible to selectively suppress the warning
132+
using the [`@nowarn` annotation](https://www.scala-lang.org/api/current/scala/annotation/nowarn.html):
133+
134+
```scala
135+
import scala.annotation.nowarn
136+
137+
class A
138+
class B extends A
139+
140+
given A()
141+
given B()
142+
143+
@nowarn("msg=Given search preference")
144+
val x = summon[A]
145+
```
146+
147+
For more details, you can consult the guide on [configuring and suppressing warnings]({{ site.baseurl }}/2021/01/12/configuring-and-suppressing-warnings.html).
148+
120149
### Resorting to Explicit Parameters
121150

122151
If the pre-3.5 behavior is preferred, you can explicitly pass the
@@ -167,11 +196,13 @@ hierarchies of classes that provide `given` instances. By importing the
167196
`given` instances from the object with the highest priority, you can
168197
control which instance is selected by the compiler.
169198

170-
**Note**: Due to the release cut-off, Scala 3.5.0 may still report a
199+
#### Upcoming Bugfixes
200+
201+
Due to the release cut-off, Scala 3.5.0 may still report a
171202
warning that the above pattern will be ambiguous in Scala
172203
3.6. However, this warning is incorrect. The issue has already been
173-
resolved, and the improvements will be included in an upcoming bugfix
174-
release.
204+
resolved, and an upcoming bugfix release will improve the
205+
accuracy of warnings.
175206

176207

177208
### Outlook

0 commit comments

Comments
 (0)