Skip to content

Rework Reflect Constant #9914

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 1 commit into from
Sep 30, 2020

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Sep 29, 2020

The current definition of Constant.unapply is unsound because there is no way to tests if the constant contains a Type.
We added Constant.ClassTag.unapply to work around this limitation, but the original was still unsound.
That definition has it's own design flaws.

To properly match all constants we provide an extractor for each kind of constant.
This has the added advantage of being able to scale if new constants are added later.
We also rename Constant.ClassTag to ClassOf as it represent a classOf[T].

@nicolasstucki nicolasstucki self-assigned this Sep 29, 2020
@nicolasstucki nicolasstucki force-pushed the rework-reflect-constant branch from e8b64b4 to 933ce20 Compare September 29, 2020 20:22
@nicolasstucki nicolasstucki force-pushed the rework-reflect-constant branch 5 times, most recently from becf516 to c7c057e Compare September 30, 2020 08:00
The current definition of Constant.unapply is unsound because there is no way to tests if the constant contains a `Type`.
We added `Constant.ClassTag.unapply` to work around this limitation, but the original was still unsound.
That definition has it's own design flaws.

To properly match all constants we provide an extractor for each kind of constant.
This has the added advantage of being able to scale if new constants are added later.
We also rename `Constant.ClassTag` to `ClassOf` as it represent a `classOf[T]`.
@nicolasstucki nicolasstucki force-pushed the rework-reflect-constant branch from c7c057e to edff735 Compare September 30, 2020 11:27
@nicolasstucki nicolasstucki marked this pull request as ready for review September 30, 2020 11:42
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

@nicolasstucki nicolasstucki merged commit 83ffe66 into scala:master Sep 30, 2020
@nicolasstucki nicolasstucki deleted the rework-reflect-constant branch September 30, 2020 13:57
rssh added a commit to dotty-cps-async/dotty-cps-async that referenced this pull request Oct 1, 2020
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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