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.
746
+
-In a `WildcardSelector`, `_` is equivalent to `*`, to be deprecated in the future.
747
+
748
+
An `ImportSpecifier` that is a single `NamedSelector` or `WildcardSelector` is equivalent to an `‘{‘ ImportSelectors ‘}‘` list with that single selector.
749
+
750
+
Animportclausewithmultipleimportexpressions`import ´p_1´.´I_1, ..., p_n´.´I_n´`isinterpreted as asequenceofimportclauses`import ´p_1´.´I_1´; ...; import ´p_n´.´I_n´`.
739
751
740
-
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.
753
+
Theimportspecifierdeterminesasetofnamesofimportablemembersof ´p´ whicharemadeavailablewithoutqualification as well as asetofimportable`given`memberswhicharemadeavailableintheimplicitscope.
742
754
A member ´m´ of ´p´ is _importable_ if it is [accessible](05-classes-and-objects.html#modifiers).
743
-
The most general form of an importexpressionisalistof_importselectors_
755
+
The most general form of an importspecifierisalistof_importselectors_
744
756
745
757
```scala
746
-
{ ´x_1´ => ´y_1, ..., x_n´ => ´y_n´, _ }
758
+
{ ´x_1´ as ´y_1, ..., x_n´ as ´y_n´, *, given ´T_1´, ..., given ´T_m´, given }
747
759
```
748
760
749
-
for ´n \geq 0´, where the final wildcard `‘_’` may be absent.
750
-
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
751
-
´y_i´.
752
-
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.
761
+
for ´n \geq 0´ and ´m \geq 0´, where the wildcards `‘*’` and `’given’` may be absent.
762
+
They are decomposed into non-givenselectors and givenselectors.
753
763
754
-
Import selectors work in the same way fortypeand term members.
755
-
For instance, an importclause`import ´p´.{´x´ => ´y\,´}`renamestheterm
756
-
name `´p´.´x´` to the term name ´y´ and the typename `´p´.´x´` to the typename ´y´.
764
+
###Non-givenImports
765
+
766
+
Non-givenselectors make available each importable member `´p´.´x_i´` under the unqualified name ´y_i´.
767
+
In other words, every importselector`´x_i´ as ´y_i´`renames`´p´.´x_i´`to ´y_i´.
768
+
When `as ´y_i´` is omitted, ´y_i´ is assumed to be ´x_i´.
769
+
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.
770
+
771
+
Non-givenimport selectors work in the same way fortypeand term members.
772
+
For instance, an importclause`import ´p´.{´x´ => ´y´}`renamesthetermname`´p´.´x´`tothetermname ´y´ andthetypename`´p´.´x´`tothetypename ´y´.
757
773
At least one of these two names must reference an importable member of ´p´.
758
774
759
-
If the target in an importselectorisawildcard, theimportselectorhidesaccesstothesourcemember.
760
-
For instance, the importselector`´x´ => _` “renames” ´x´ tothewildcardsymbol (whichisunaccessible as anameinuserprograms), andtherebyeffectivelypreventsunqualifiedaccessto ´x´.
775
+
If the target in an importselectorisanunderscore`as _`, theimportselectorhidesaccesstothesourcememberinsteadofimportingit.
776
+
For instance, the importselector`´x´ as _` “renames” ´x´ totheunderscoresymbol (whichisnotaccessible as anameinuserprograms), andtherebyeffectivelypreventsunqualifiedaccessto ´x´.
761
777
This is useful if there is a final wildcard in the same importselectorlist, whichimportsallmembersnotmentionedinpreviousimportselectors.
762
778
763
-
The scope of a binding introduced by an import-clause starts immediately after the importclauseandextendstotheendoftheenclosingblock, template, packageclause, orcompilationunit, whichevercomesfirst.
779
+
The scope of a binding introduced by a non-givenimportclause starts immediately after the importclauseandextendstotheendoftheenclosingblock, template, packageclause, orcompilationunit, whichevercomesfirst.
764
780
765
-
Several shorthands exist. Animportselectormaybejustasimplename ´x´.
766
-
Inthiscase, ´x´ is imported without renaming, so the importselectorisequivalentto`´x´ => ´x´`.
767
-
Furthermore, it is possible to replace the whole importselectorlistbyasingleidentifierorwildcard.
768
-
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).
781
+
###GivenImports
769
782
770
-
Animportclausewithmultipleimportexpressions`import ´p_1´.´I_1, ..., p_n´.´I_n´`isinterpreted as asequenceofimportclauses`import ´p_1´.´I_1´; ...; import ´p_n´.´I_n´`.
783
+
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´.
784
+
A bare `given` selector without typeis equivalent to `given scala.Any`.
785
+
786
+
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