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
-In a `NamedSelector`, `=>` can only be used when inside an `ImportSelectors` and is then equivalent to `as`, to be deprecated in the future.
709
+
-In a `WildcardSelector`, `_` is equivalent to `*`, to be deprecated in the future.
710
+
711
+
An `ImportSpecifier` that is a single `NamedSelector` or `WildcardSelector` is equivalent to an `‘{‘ ImportSelectors ‘}‘` list with that single selector.
712
+
713
+
Animportclausewithmultipleimportexpressions`import ´p_1´.´I_1, ..., p_n´.´I_n´`isinterpreted as asequenceofimportclauses`import ´p_1´.´I_1´; ...; import ´p_n´.´I_n´`.
702
714
703
-
Animportclausehastheform`import ´p´.´I´`where ´p´ isa [stableidentifier](03-types.html#paths) and ´I´ isanimportexpression.
Animportclausewithasingleimportexpressionhastheform`import ´p´.´I´`where ´p´ isa [prefix](03-types.html#designator-types) and ´I´ isanimportspecifier.
716
+
Theimportspecifierdeterminesasetofnamesofimportablemembersof ´p´ whicharemadeavailablewithoutqualification as well as asetofimportable`given`memberswhicharemadeavailableintheimplicitscope.
705
717
A member ´m´ of ´p´ is _importable_ if it is [accessible](05-classes-and-objects.html#modifiers).
706
-
The most general form of an importexpressionisalistof_importselectors_
718
+
The most general form of an importspecifierisalistof_importselectors_
707
719
708
720
```scala
709
-
{ ´x_1´ => ´y_1, ..., x_n´ => ´y_n´, _ }
721
+
{ ´x_1´ as ´y_1, ..., x_n´ as ´y_n´, *, given ´T_1´, ..., given ´T_m´, given }
710
722
```
711
723
712
-
for ´n \geq 0´, where the final wildcard `‘_’` may be absent.
713
-
It makes available each importable member `´p´.´x_i´` under the unqualified name ´y_i´. I.e. every importselector`´x_i´ => ´y_i´`renames`´p´.´x_i´`to
714
-
´y_i´.
715
-
If a final wildcard is present, all importable members ´z´ of ´p´ other than `´x_1, ..., x_n,y_1, ..., y_n´` are also made available under their own unqualified names.
724
+
for ´n \geq 0´ and ´m \geq 0´, where the wildcards `‘*’` and `’given’` may be absent.
725
+
They are decomposed into non-givenselectors and givenselectors.
716
726
717
-
Import selectors work in the same way fortypeand term members.
718
-
For instance, an importclause`import ´p´.{´x´ => ´y\,´}`renamestheterm
719
-
name `´p´.´x´` to the term name ´y´ and the typename `´p´.´x´` to the typename ´y´.
727
+
###Non-givenImports
728
+
729
+
Non-givenselectors make available each importable member `´p´.´x_i´` under the unqualified name ´y_i´.
730
+
In other words, every importselector`´x_i´ as ´y_i´`renames`´p´.´x_i´`to ´y_i´.
731
+
When `as ´y_i´` is omitted, ´y_i´ is assumed to be ´x_i´.
732
+
If a final wildcard `‘*’` is present, all non-`given` importable members ´z´ of ´p´ other than `´x_1, ..., x_n, y_1, ..., y_n´` are also made available under their own unqualified names.
733
+
734
+
Non-givenimport selectors work in the same way fortypeand term members.
735
+
For instance, an importclause`import ´p´.{´x´ => ´y´}`renamesthetermname`´p´.´x´`tothetermname ´y´ andthetypename`´p´.´x´`tothetypename ´y´.
720
736
At least one of these two names must reference an importable member of ´p´.
721
737
722
-
If the target in an importselectorisawildcard, theimportselectorhidesaccesstothesourcemember.
723
-
For instance, the importselector`´x´ => _` “renames” ´x´ tothewildcardsymbol (whichisunaccessible as anameinuserprograms), andtherebyeffectivelypreventsunqualifiedaccessto ´x´.
738
+
If the target in an importselectorisanunderscore`as _`, theimportselectorhidesaccesstothesourcememberinsteadofimportingit.
739
+
For instance, the importselector`´x´ as _` “renames” ´x´ totheunderscoresymbol (whichisnotaccessible as anameinuserprograms), andtherebyeffectivelypreventsunqualifiedaccessto ´x´.
724
740
This is useful if there is a final wildcard in the same importselectorlist, whichimportsallmembersnotmentionedinpreviousimportselectors.
725
741
726
-
The scope of a binding introduced by an import-clause starts immediately after the importclauseandextendstotheendoftheenclosingblock, template, packageclause, orcompilationunit, whichevercomesfirst.
742
+
The scope of a binding introduced by a non-givenimportclause starts immediately after the importclauseandextendstotheendoftheenclosingblock, template, packageclause, orcompilationunit, whichevercomesfirst.
727
743
728
-
Several shorthands exist. Animportselectormaybejustasimplename ´x´.
729
-
Inthiscase, ´x´ is imported without renaming, so the importselectorisequivalentto`´x´ => ´x´`.
730
-
Furthermore, it is possible to replace the whole importselectorlistbyasingleidentifierorwildcard.
731
-
Theimportclause`import ´p´.´x´`isequivalentto`import ´p´.{´x\,´}`, i.e. itmakesavailablewithoutqualificationthemember ´x´ of ´p´. Theimportclause`import ´p´._`isequivalentto`import ´p´.{_}`, i.e. itmakesavailablewithoutqualificationallmembersof ´p´ (thisisanalogousto`import ´p´.*`inJava).
744
+
###GivenImports
732
745
733
-
Animportclausewithmultipleimportexpressions`import ´p_1´.´I_1, ..., p_n´.´I_n´`isinterpreted as asequenceofimportclauses`import ´p_1´.´I_1´; ...; import ´p_n´.´I_n´`.
746
+
Given selectors make available in the implicit scope all the importable `given` and `implicit` members `´p´.´x´` such that `´p.x´` is a subtype of ´T_i´.
747
+
A bare `given` selector without typeis equivalent to `given scala.Any`.
748
+
749
+
The names of the givenmembers are irrelevant for the selection, and are not made available in the normal scope of unqualified names.
0 commit comments