Skip to content

Change rules for exports to make them more useful for enums #6729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 9, 2019

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jun 22, 2019

Two changes:

  1. The forwarder aliasing a value definition gets a singleton type referring
    to the alias.
  2. Synthetic members are not exported by a wildcard export.

This means we can now safely write

  enum MatchDegree {
    case NoMatch, ParamMatch, FullMatch
  }
  export MatchDegree._

and export just the three enum values with the most precise types. (precision
is necessary for exhaustiveness checks, among others).

@odersky odersky force-pushed the change-export-rules branch 2 times, most recently from 57da77f to 01f6669 Compare June 24, 2019 12:26
odersky added 3 commits July 5, 2019 13:28
Two changes:

 - The forwarder alising a value definition gets a singleton type referring
   to the alias
 - Synthetic members are not exported by a wildcard export

This means we can now safely write
```
  enum MatchDegree {
    case NoMatch, ParamMatch, FullMatch
  }
  export MatchDegree._
```
and export just the three enum values with the most precise types. (precision
is necessary for exhaustiveness checks, among others).
odersky added 3 commits July 8, 2019 14:02
Leaks can be avoided by following type aliases. Previously, this was only
done if the checked symbol is a term. But it is not clear why types should
not get the same treatment. This avoids a problem in pos/reference/exports.scala.
We export values under their singleton types only if the
original value was already public. Otherwise this would
provoke a leak.
@nicolasstucki nicolasstucki merged commit bbc0df7 into scala:master Jul 9, 2019
@nicolasstucki nicolasstucki deleted the change-export-rules branch July 9, 2019 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants