Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow soft keywords
open
and infix
under -Xsource:3
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.
- Loading branch information
Showing
5 changed files
with
100 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
open-infix-future.scala:4: error: expected class or object definition | ||
open trait A // error | ||
^ | ||
open-infix-future.scala:5: error: expected class or object definition | ||
open object B // error | ||
^ | ||
open-infix-future.scala:8: error: ';' expected but 'val' found. | ||
infix val a: Int = 1 // error | ||
^ | ||
open-infix-future.scala:9: error: ';' expected but 'var' found. | ||
infix var b: Int = 1 // error | ||
^ | ||
open-infix-future.scala:11: error: ';' expected but 'type' found. | ||
open type D // error | ||
^ | ||
open-infix-future.scala:14: error: illegal start of statement | ||
open class E // error | ||
^ | ||
open-infix-future.scala:15: error: ';' expected but 'def' found. | ||
open def bla(y: Int) = y // error | ||
^ | ||
7 errors |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// scalac: -Xsource:3 | ||
// | ||
|
||
open class A | ||
infix class B[T, S] | ||
|
||
open infix class C[T, S] | ||
open infix case class CC[T, S](x: Int) | ||
infix open class D[T, S] | ||
infix trait DT[T, S] | ||
|
||
open | ||
infix | ||
private | ||
class E | ||
|
||
class F { | ||
open infix class C1[T, S] | ||
infix type X | ||
|
||
infix def foo(x: Int): Int = x | ||
} | ||
|
||
object G { | ||
open infix class C2[T, S] | ||
} | ||
|
||
object Test { | ||
val infix: Int = 1 | ||
infix + 1 | ||
val open: Int => Int = x => x | ||
open(1) | ||
open { | ||
2 | ||
} | ||
} |