Skip to content

Add TASTy Reflect Pattern.Wildcard #6275

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

Conversation

nicolasstucki
Copy link
Contributor

Wildcard are represented with Ident but are not valid terms. The current API exposed them an the contens on a Pattern.Value which advertives them as Terms. To avoid we add Pattern.Wildcard and stop returning them from Pattern.Value.

@nicolasstucki nicolasstucki self-assigned this Apr 10, 2019
@nicolasstucki
Copy link
Contributor Author

This inconsistency was discovered while implementing #6274

@nicolasstucki nicolasstucki force-pushed the add-tasty-reflect-pattern-wildcard branch 5 times, most recently from da6bc89 to 7ff2fee Compare April 10, 2019 14:34
@nicolasstucki nicolasstucki marked this pull request as ready for review April 10, 2019 15:28
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.

Otherwise, LGTM

@@ -304,6 +305,9 @@ trait Core {
/** Pattern representing a `x: Y` type test. */
type TypeTest = kernel.TypeTest

/** Pattern representing a `_` pattern */
type Wildcard = kernel.Wildcard

Copy link
Contributor

Choose a reason for hiding this comment

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

A little concern for flattened Pattern names: Wildcard has different meanings in different places, it may cause confusion.

Maybe WildcardPattern -- as most macros will not touch patterns, a long name will not affect usability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed it to WildcardPattern

Wildcard are represented with Ident but are not valid terms. The current API exposed them an the contens on a Pattern.Value which advertives them as Terms. To avoid we add Pattern.WildcardPattern and stop returning them from Pattern.Value.
@nicolasstucki nicolasstucki force-pushed the add-tasty-reflect-pattern-wildcard branch from 7ff2fee to 59e378a Compare April 11, 2019 07:59
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

def unapply(pattern: Pattern)(implicit ctx: Context): Boolean =
kernel.matchPattern_WildcardPattern(pattern).isDefined
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Minor (no need to address in this PR): we could use just Wildcard here, as there is no worry for conflict or confusion.

Maybe we can avoid flattening types for seldomly used categories like TypeTrees and Patterns to reduce conflicts and confusions.

@nicolasstucki nicolasstucki merged commit 255da96 into scala:master Apr 11, 2019
@ghost ghost removed the stat:needs review label Apr 11, 2019
@nicolasstucki nicolasstucki deleted the add-tasty-reflect-pattern-wildcard branch April 11, 2019 12:02
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.

2 participants