Skip to content

Commit 7ebdc1c

Browse files
committed
update export.md
1 parent 3aa5f76 commit 7ebdc1c

File tree

1 file changed

+20
-9
lines changed
  • docs/docs/reference/other-new-features

1 file changed

+20
-9
lines changed

docs/docs/reference/other-new-features/export.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ An export clause has the same format as an import clause. Its general form is:
4747

4848
```scala
4949
export path . { sel_1, ..., sel_n }
50-
export given path . { sel_1, ..., sel_n }
5150
```
5251

5352
It consists of a qualifier expression `path`, which must be a stable identifier, followed by
@@ -58,7 +57,8 @@ of one of the following forms:
5857
- A _renaming selector_ `x => y` creates aliases for all eligible members of `path` that are named `x`, but the alias is named `y` instead of `x`.
5958
- An _omitting selector_ `x => _` prevents `x` from being aliased by a subsequent
6059
wildcard selector.
61-
- A _wildcard selector_ creates aliases for all eligible members of `path` except for
60+
- A _given selector_ `given x` has an optional type bound `x`. It creates aliases for all eligible given instances that conform to either `x`, or `Any` if `x` is omitted, except for members that are named by a previous simple, renaming, or omitting selector.
61+
- A _wildcard selector_ `_` creates aliases for all eligible members of `path` except for given instances,
6262
synthetic members generated by the compiler and those members that are named by a previous simple, renaming, or omitting selector.
6363

6464
A member is _eligible_ if all of the following holds:
@@ -68,8 +68,7 @@ A member is _eligible_ if all of the following holds:
6868
a base class of the class containing the export clause.
6969
- it is accessible at the export clause,
7070
- it is not a constructor, nor the (synthetic) class part of an object,
71-
- it is a given instance (or an old-style `implicit` value)
72-
if and only if the export is tagged with `given`.
71+
- it is a given instance (declared with `given`) if and only if the export is from a _given selector_.
7372

7473
It is a compile-time error if a simple or renaming selector does not identify any eligible
7574
members.
@@ -95,6 +94,8 @@ def f: c.T = ...
9594
<a id="note_class"></a>
9695
Export clauses can appear in classes or they can appear at the top-level. An export clause cannot appear as a statement in a block.
9796

97+
If an export clause contains a wildcard or given selector, it is forbidden for its qualifier path to refer to a package. This is because it is not yet known how to safely track wildcard dependencies to a package for the purposes of incremental compilation.
98+
9899
(\*) **Note:** Unless otherwise stated, the term "class" in this discussion also includes object and trait definitions.
99100

100101
## Motivation
@@ -111,11 +112,21 @@ more flexible way.
111112
## Syntax changes:
112113

113114
```
114-
TemplateStat ::= ...
115-
| Export
116-
TopStat ::= ...
117-
| Export
118-
Export ::= ‘export’ [‘given’] ImportExpr {‘,’ ImportExpr}
115+
TemplateStat ::= ...
116+
| Export
117+
TopStat ::= ...
118+
| Export
119+
Import ::= ‘import’ ImportExpr {‘,’ ImportExpr}
120+
ImportExpr ::= StableId ‘.’ ImportSpec
121+
ImportSpec ::= id
122+
| ‘_’
123+
| ‘given’
124+
| ‘{’ ImportSelectors) ‘}’
125+
ImportSelectors ::= id [‘=>’ id | ‘=>’ ‘_’] [‘,’ ImportSelectors]
126+
| WildCardSelector {‘,’ WildCardSelector}
127+
WildCardSelector ::= ‘_'
128+
| ‘given’ [InfixType]
129+
Export ::= ‘export’ ImportExpr {‘,’ ImportExpr}
119130
```
120131

121132
## Elaboration of Export Clauses

0 commit comments

Comments
 (0)