Skip to content

Allow soft keywords open and infix under -Xsource:3#9580

Merged
lrytz merged 1 commit intoscala:2.13.xfrom
smarter:open-infix
Apr 21, 2021
Merged

Allow soft keywords open and infix under -Xsource:3#9580
lrytz merged 1 commit intoscala:2.13.xfrom
smarter:open-infix

Conversation

@smarter
Copy link
Member

@smarter smarter commented Apr 19, 2021

Since everything is open and can be used infix by default in Scala 2,
these keywords are no-op, but they're useful for cross-compiling with a
future version of Scala 3 where they will be required in some
cases (with Scala 3.0 they're only required to avoid warnings under
-source future).

See https://dotty.epfl.ch/docs/reference/changed-features/operators.html
and http://dotty.epfl.ch/docs/reference/other-new-features/open-classes.html
for details.

@scala-jenkins scala-jenkins added this to the 2.13.6 milestone Apr 19, 2021
@SethTisue SethTisue added the release-notes worth highlighting in next release notes label Apr 19, 2021
@lrytz
Copy link
Member

lrytz commented Apr 20, 2021

There's a change of semantics here, this used to run the infix method:

scala> class C {
     |   def infix = println("hi")
     |   infix
     |   def f = 1
     | }
class C

scala> new C
val res0: C = C@7b451bf4

Is there an easy way to issue an error here? Or is it exotic enougth to be ignored?

@smarter
Copy link
Member Author

smarter commented Apr 20, 2021

I'd say that's an inevitable semantic change, emitting a warning or error would be very tricky since it would require both token-level information and name resolution

Since everything is open and can be used infix by default in Scala 2,
these keywords are no-op, but they're useful for cross-compiling with a
future version of Scala 3 where they will be required in some
cases (with Scala 3.0 they're only required to avoid warnings under
`-source future`).

See https://dotty.epfl.ch/docs/reference/changed-features/operators.html
and http://dotty.epfl.ch/docs/reference/other-new-features/open-classes.html
for details.
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.

👍 thanks for the rebase

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