@@ -14,22 +14,22 @@ object A {
1414
1515object B {
1616 import A ._
17- import A .{ given _ }
17+ import A .given
1818}
1919```
2020
2121In the code above, the ` import A._ ` clause of object ` B ` will import all members
22- of ` A ` _ except_ the given instance ` tc ` . Conversely, the second import ` import A.{ given _} ` will import _ only_ that given instance.
22+ of ` A ` _ except_ the given instance ` tc ` . Conversely, the second import ` import A.given ` will import _ only_ that given instance.
2323The two import clauses can also be merged into one:
2424
2525``` scala
2626object B {
27- import A .{given _ , _ }
27+ import A .{given , _ }
2828}
2929```
3030
3131Generally, a normal wildcard selector ` _ ` brings all definitions other than givens or extensions into scope
32- whereas a ` given _ ` selector brings all givens (including those resulting from extensions) into scope.
32+ whereas a ` given ` selector brings all givens (including those resulting from extensions) into scope.
3333
3434There are two main benefits arising from these rules:
3535
@@ -106,13 +106,13 @@ normal imports to givens and given imports.
106106The following modifications avoid this hurdle to migration.
107107
108108 1 . A ` given ` import selector also brings old style implicits into scope. So, in Scala 3.0
109- an old-style implicit definition can be brought into scope either by a ` _ ` or a ` given _ ` wildcard selector.
109+ an old-style implicit definition can be brought into scope either by a ` _ ` or a ` given ` wildcard selector.
110110
111111 2 . In Scala 3.1, old-style implicits accessed through a ` _ ` wildcard import will give a deprecation warning.
112112
113113 3 . In some version after 3.1, old-style implicits accessed through a ` _ ` wildcard import will give a compiler error.
114114
115- These rules mean that library users can use ` given _ ` selectors to access old-style implicits in Scala 3.0,
115+ These rules mean that library users can use ` given ` selectors to access old-style implicits in Scala 3.0,
116116and will be gently nudged and then forced to do so in later versions. Libraries can then switch to
117117given instances once their user base has migrated.
118118
@@ -123,10 +123,11 @@ Import ::= ‘import’ ImportExpr {‘,’ ImportExpr}
123123ImportExpr ::= StableId ‘.’ ImportSpec
124124ImportSpec ::= id
125125 | ‘_’
126+ | ‘given’
126127 | ‘{’ ImportSelectors) ‘}’
127128ImportSelectors ::= id [‘=>’ id | ‘=>’ ‘_’] [‘,’ ImportSelectors]
128129 | WildCardSelector {‘,’ WildCardSelector}
129130WildCardSelector ::= ‘_'
130- | ‘given’ (‘_' | InfixType)
131+ | ‘given’ [ InfixType]
131132Export ::= ‘export’ ImportExpr {‘,’ ImportExpr}
132133```
0 commit comments