Skip to content

Commit 82394f2

Browse files
committed
Specify export restrictions more precisely in doc page
1 parent 56f993e commit 82394f2

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

docs/docs/reference/changed-features/imports.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ are offered under settings `-source 3.1-migration -rewrite`.
4747

4848
```
4949
Import ::= ‘import’ ImportExpr {‘,’ ImportExpr}
50-
Export ::= ‘export’ ImportExpr {‘,’ ImportExpr}
5150
ImportExpr ::= SimpleRef {‘.’ id} ‘.’ ImportSpec
5251
ImportSpec ::= NamedSelector
5352
| WildcardSelector

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

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ A member is _eligible_ if all of the following holds:
7070
- it is not a constructor, nor the (synthetic) class part of an object,
7171
- it is a given instance (declared with `given`) if and only if the export is from a _given selector_.
7272

73-
It is a compile-time error if a simple or renaming selector does not identify any eligible
74-
members.
73+
It is a compile-time error if a simple or renaming selector does not identify any eligible members.
7574

7675
Type members are aliased by type definitions, and term members are aliased by method definitions. Export aliases copy the type and value parameters of the members they refer to.
7776
Export aliases are always `final`. Aliases of given instances are again defined as givens (and aliases of old-style implicits are `implicit`). Aliases of inline methods or values are again defined `inline`. There are no other modifiers that can be given to an alias. This has the following consequences for overriding:
@@ -91,11 +90,21 @@ export O.c
9190
def f: c.T = ...
9291
```
9392

94-
<a id="note_class"></a>
95-
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.
9693

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.
94+
**Restrictions:**
95+
96+
1. 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.
97+
1. 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+
99+
1. Simple renaming exports like
100+
```scala
101+
export status as stat
102+
```
103+
are not supported yet. They would run afoul of the restriction that the
104+
exported `a` cannot be already a member of the object containing the export.
105+
This restriction might be lifted in the future.
98106

107+
<a id="note_class"></a>
99108
(\*) **Note:** Unless otherwise stated, the term "class" in this discussion also includes object and trait definitions.
100109

101110
## Motivation
@@ -116,17 +125,15 @@ TemplateStat ::= ...
116125
| Export
117126
TopStat ::= ...
118127
| 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]
129128
Export ::= ‘export’ ImportExpr {‘,’ ImportExpr}
129+
ImportExpr ::= SimpleRef {‘.’ id} ‘.’ ImportSpec
130+
ImportSpec ::= NamedSelector
131+
| WildcardSelector
132+
| ‘{’ ImportSelectors) ‘}’
133+
NamedSelector ::= id [‘as’ (id | ‘_’)]
134+
WildCardSelector ::= ‘*' | ‘given’ [InfixType]
135+
ImportSelectors ::= NamedSelector [‘,’ ImportSelectors]
136+
| WildCardSelector {‘,’ WildCardSelector}
130137
```
131138
132139
## Elaboration of Export Clauses

0 commit comments

Comments
 (0)