-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix #10857: export from wildcard defs with same name as user declared ones #10949
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
Conversation
f79059f
to
a00e5b5
Compare
@main def Test = | ||
|
||
println(Module.Red) | ||
println(Module.valueOf("Red")) // error: value valueOf is not a member |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. here valueOf
is still not exported from the enum because there is no user declared definition that matches that name
a00e5b5
to
f822019
Compare
I have put for RC1 because if we accept this change, the API generated will change for the same source code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec for exports.md needs to be updated as well to reflect the new behavior
@odersky I have updated the documentation |
@@ -60,8 +60,7 @@ A member is _eligible_ if all of the following holds: | |||
a base class of the class containing the export clause. | |||
- it is accessible at the export clause, | |||
- it is not a constructor, nor the (synthetic) class part of an object, | |||
- it is a given instance (or an old-style `implicit` value) | |||
if and only if the export is tagged with `given`. | |||
- it is a given instance (declared with `given`) if and only if the export is from a _given selector_. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change comes from observation that implicit forwarders are only generated from wildcard selectors and not given selectors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM
@odersky I have implemented the changes to documentation |
a wildcard export will first search for all public and non-synthetic members to add. Then once a valid member is found, that name is then used to search for all term or type members that use that name and are not given or private. As a consequence members like companion objects to case classes will be exported alongside a type alias to the case class
a wildcard export will first search for all public and
non-synthetic members to add. Then once a valid member
is found, that name is then used to search for all
term or type members that use that name and are not
given or private.
Status Quo for wildcard given exports.
As a consequence members like companion objects to
case classes will be exported alongside a type alias
to the case class
Fixes #10857