Skip to content

Use new extension syntax in scala.tasty.Reflection #9311

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
Jul 8, 2020

Conversation

nicolasstucki
Copy link
Contributor

Extension are placed within the module of the type. For example, the extension Tree.pos
will be available explicitly and in the documentation as Tree.extension_pos.
We still need to add an given XYZOps as XYZ.type = XYZ to make the extension methods available.

@nicolasstucki nicolasstucki self-assigned this Jul 7, 2020
@nicolasstucki nicolasstucki force-pushed the use-new-extension-syntax branch 2 times, most recently from 36887b9 to ea13bbc Compare July 7, 2020 11:22
@nicolasstucki nicolasstucki marked this pull request as ready for review July 7, 2020 12:00
@nicolasstucki nicolasstucki requested a review from liufengyun July 7, 2020 12:00
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

LGTM

Community build failed.

extension ContextOps on (self: Context) {
/** Returns the owner of the context */
def owner: Symbol = internal.Context_owner(self)
given ContextOps as Context.type = Context
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to suggest something is wrong with the language design.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is more about the automatically imported scopes for abstract types. With opaque types we look into the module but for these ones we are missing it. I plan on minimizing this limitation and ideally remove those givens later

object Context:
extension (self: Context):
/** Returns the owner of the context */
def owner: Symbol = internal.Context_owner(self)
Copy link
Contributor

Choose a reason for hiding this comment

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

The previous extension methods syntax seems much better for this use case.

@nicolasstucki nicolasstucki force-pushed the use-new-extension-syntax branch 2 times, most recently from dd81139 to 43bbbdd Compare July 7, 2020 15:02
Extension are placed within the module of the type. For example, the extension `Tree.pos`
will be available explicitly and in the documentation as `Tree.extension_pos`.
We still need to add an `given XYZOps as XYZ.type = XYZ` to make the extension methods available.
@nicolasstucki nicolasstucki force-pushed the use-new-extension-syntax branch from 43bbbdd to df07233 Compare July 7, 2020 16:26
@nicolasstucki
Copy link
Contributor Author

@anatoliykmetyuk could you should review the changes in the community build. I removed the TraceHelper and all the useless imports it added. That pattern should never be used.

Copy link
Contributor

@anatoliykmetyuk anatoliykmetyuk left a comment

Choose a reason for hiding this comment

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

utest LGTM

@nicolasstucki nicolasstucki merged commit be1327f into scala:master Jul 8, 2020
@nicolasstucki nicolasstucki deleted the use-new-extension-syntax branch July 8, 2020 09:05
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.

4 participants