[backport] Underscore changes for -Xsource:3: parse +_/-_ and prefix wildcard variables introduced by ?-syntax with ?#9620
Merged
lrytz merged 2 commits intoscala:2.12.xfrom May 10, 2021
Conversation
…eholder syntax This change allows `kind-projector` plugin to rewrite `+_` and `-_` tokens to type lambdas, in line with proposed syntax for Scala 3.2 in http://dotty.epfl.ch/docs/reference/changed-features/wildcards.html When used in conjunction with `-Xsource:3` this will let the user use `?` for wildcards and `_` for placeholders, letting the user cross-compile the same sources with Scala 3 with `-source:3.2` flag. This change is not source breaking since currently `+_` and `-_` fail to parse entirely, this change also does not allow the user to declare types with these names without backticks, they can only be used as part of a type tree. Gate `-_`/`+_` parsing behind `-Xsource:3` to guarantee minimal disruption to existing code
This change names wildcards written with Scala 3 `?` syntax with `?$N` pattern instead of `_$N` used for Scala 2 wildcards There are two reasons for it: - To allow `kind-projector` to implement Scala 3 underscore syntax for type lambdas by transforming old-style underscores, but leaving Scala 3 underscores intact - To show a mildly more relevant error message, since a wildcard introduced by `?` will now also have a name with `?` in the error message
cc301c0 to
ac638c2
Compare
Contributor
Author
|
/rebuild |
lrytz
approved these changes
May 10, 2021
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR backports the following changes to Scala 2.12:
+_and-_in types as identifiers under-Xsource:3to support Scala 3.2 placeholder syntax #9605