Skip to content
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

[backport] Underscore changes for -Xsource:3: parse +_/-_ and prefix wildcard variables introduced by ?-syntax with ? #9620

Merged
merged 2 commits into from May 10, 2021

Conversation

neko-kai
Copy link
Contributor

@neko-kai neko-kai commented May 8, 2021

…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
@scala-jenkins scala-jenkins added this to the 2.12.14 milestone May 8, 2021
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
@neko-kai
Copy link
Contributor Author

neko-kai commented May 9, 2021

/rebuild

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes worth highlighting in next release notes
Projects
None yet
4 participants