Skip to content

Support writing & instead of with in types under -Xsource:3#9594

Merged
lrytz merged 1 commit intoscala:2.13.xfrom
smarter:and-syntax
Apr 27, 2021
Merged

Support writing & instead of with in types under -Xsource:3#9594
lrytz merged 1 commit intoscala:2.13.xfrom
smarter:and-syntax

Conversation

@smarter
Copy link
Member

@smarter smarter commented Apr 25, 2021

Instead of:

val x: A with B = new A with B {}

One can now write:

val x: A & B = new A with B {}

However mixing & with other infix operators is not allowed, because
unlike Scala 3, we do not take operator precedence into account, cf #6147.

This implementation is a bit more restrictive than the Scala 3 one which
allows shadowing the built-in & with your own & type operator, but
this cannot be done with the simple parser-based approach of this PR.

Instead of:

    val x: A with B = new A with B {}

One can now write:

    val x: A & B = new A with B {}

However mixing `&` with other infix operators is not allowed, because
unlike Scala 3, we do not take operator precedence into account, cf scala#6147.

This implementation is a bit more restrictive than the Scala 3 one which
allows shadowing the built-in `&` with your own `&` type operator, but
this cannot be done with the simple parser-based approach of this PR.
@scala-jenkins scala-jenkins added this to the 2.13.6 milestone Apr 25, 2021
@SethTisue SethTisue added the release-notes worth highlighting in next release notes label Apr 26, 2021
@smarter
Copy link
Member Author

smarter commented Apr 26, 2021

(this is the last -Xsource:3 PR I plan to make, or at least I can't think of anything else to port at the moment :))

Copy link
Member

@lrytz lrytz left a comment

Choose a reason for hiding this comment

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

this is the last -Xsource:3 PR I plan to make

Too bad, I was going to say keep them coming :-) Thanks a lot.

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

Development

Successfully merging this pull request may close these issues.

4 participants