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

Commits on May 8, 2021

  1. Parse +_ and -_ in types as identifiers to support Scala 3.2 plac…

    …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
    neko-kai committed May 8, 2021
    Configuration menu
    Copy the full SHA
    c60318f View commit details
    Browse the repository at this point in the history

Commits on May 9, 2021

  1. Differentiate Scala 2 and Scala 3 wildcard identifier names

    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 committed May 9, 2021
    Configuration menu
    Copy the full SHA
    ac638c2 View commit details
    Browse the repository at this point in the history