Skip to content

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

Merged
merged 2 commits into from
Jan 12, 2021

Conversation

bishabosha
Copy link
Member

@bishabosha bishabosha commented Dec 29, 2020

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

@main def Test =

println(Module.Red)
println(Module.valueOf("Red")) // error: value valueOf is not a member
Copy link
Member Author

@bishabosha bishabosha Dec 29, 2020

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

@bishabosha
Copy link
Member Author

bishabosha commented Dec 30, 2020

I have put for RC1 because if we accept this change, the API generated will change for the same source code

Copy link
Contributor

@odersky odersky left a 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 odersky assigned bishabosha and unassigned odersky Jan 1, 2021
@bishabosha bishabosha requested a review from odersky January 7, 2021 14:10
@bishabosha bishabosha assigned odersky and unassigned bishabosha Jan 7, 2021
@bishabosha
Copy link
Member Author

@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_.
Copy link
Member Author

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

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

@bishabosha
Copy link
Member Author

@odersky I have implemented the changes to documentation

@bishabosha bishabosha requested a review from odersky January 11, 2021 11:23
@bishabosha bishabosha assigned odersky and unassigned bishabosha Jan 11, 2021
@odersky odersky assigned bishabosha and unassigned odersky Jan 12, 2021
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
@bishabosha bishabosha merged commit 8345078 into scala:master Jan 12, 2021
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.

Wildcard export ignores synthetic members generated from desugaring
3 participants