Skip to content

Commit d18b8b0

Browse files
committed
update export.md
1 parent f822019 commit d18b8b0

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
@@ -40,7 +40,6 @@ copier.print(copier.scan())
4040
An export clause has the same format as an import clause. Its general form is:
4141
```scala
4242
export path . { sel_1, ..., sel_n }
43-
export given path . { sel_1, ..., sel_n }
4443
```
4544
It consists of a qualifier expression `path`, which must be a stable identifier, followed by
4645
one or more selectors `sel_i` that identify what gets an alias. Selectors can be
@@ -50,7 +49,8 @@ of one of the following forms:
5049
- 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`.
5150
- An _omitting selector_ `x => _` prevents `x` from being aliased by a subsequent
5251
wildcard selector.
53-
- A _wildcard selector_ creates aliases for all eligible members of `path` except for
52+
- 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.
53+
- A _wildcard selector_ `_` creates aliases for all eligible members of `path` except for given instances,
5454
synthetic members generated by the compiler and those members that are named by a previous simple, renaming, or omitting selector.
5555

5656
A member is _eligible_ if all of the following holds:
@@ -60,8 +60,7 @@ A member is _eligible_ if all of the following holds:
6060
a base class of the class containing the export clause.
6161
- it is accessible at the export clause,
6262
- it is not a constructor, nor the (synthetic) class part of an object,
63-
- it is a given instance (or an old-style `implicit` value)
64-
if and only if the export is tagged with `given`.
63+
- it is a given instance (declared with `given`) if and only if the export is from a _given selector_.
6564

6665
It is a compile-time error if a simple or renaming selector does not identify any eligible
6766
members.
@@ -87,6 +86,8 @@ def f: c.T = ...
8786
<a id="note_class"></a>
8887
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.
8988

89+
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.
90+
9091
(\*) Note: Unless otherwise stated, the term "class" in this discussion also includes object and trait definitions.
9192

9293
## Motivation
@@ -103,11 +104,21 @@ more flexible way.
103104
## Syntax changes:
104105

105106
```
106-
TemplateStat ::= ...
107-
| Export
108-
TopStat ::= ...
109-
| Export
110-
Export ::= ‘export’ [‘given’] ImportExpr {‘,’ ImportExpr}
107+
TemplateStat ::= ...
108+
| Export
109+
TopStat ::= ...
110+
| Export
111+
Import ::= ‘import’ ImportExpr {‘,’ ImportExpr}
112+
ImportExpr ::= StableId ‘.’ ImportSpec
113+
ImportSpec ::= id
114+
| ‘_’
115+
| ‘given’
116+
| ‘{’ ImportSelectors) ‘}’
117+
ImportSelectors ::= id [‘=>’ id | ‘=>’ ‘_’] [‘,’ ImportSelectors]
118+
| WildCardSelector {‘,’ WildCardSelector}
119+
WildCardSelector ::= ‘_'
120+
| ‘given’ [InfixType]
121+
Export ::= ‘export’ ImportExpr {‘,’ ImportExpr}
111122
```
112123

113124
## Elaboration of Export Clauses

0 commit comments

Comments
 (0)