Remove logic to check if a named arg could be an assignment (and enable -Xsource:2.13 by default)#6092
Conversation
Issue a deprecation warning when an assignment expression (`x = e`) in a parameter position is treated as an assignment, not a named argument. In 2.13 this will be an error, `f(x = e)` will be restricted to named arguments and never be treated as an assignment to `x`. The 2.13 behavior is available under `-Xsource:2.13` See scala/scala-dev#426
|
Hehe, our current 2.13.x branch doesn't compile with |
| val reporter = StringSetting ("-Xreporter", "classname", "Specify a custom reporter for compiler messages.", "scala.tools.nsc.reporters.ConsoleReporter") | ||
| val strictInference = BooleanSetting ("-Xstrict-inference", "Don't infer known-unsound types") | ||
| val source = ScalaVersionSetting ("-Xsource", "version", "Treat compiler input as Scala source for the specified version, see scala/bug#8126.", initial = ScalaVersion("2.12")) | ||
| val source = ScalaVersionSetting ("-Xsource", "version", "Treat compiler input as Scala source for the specified version, see scala/bug#8126.", initial = ScalaVersion("2.13")) |
| * assignment (to figure out if the expression was a valid assignment, a4a892fb01). Since 2.13 we | ||
| * could use a normal NormalTypeError, but I'll leave it in for now, it might come in handy. | ||
| */ | ||
| class NormalTypeErrorFromCyclicReference(underlyingTree: Tree, errMsg: String) |
There was a problem hiding this comment.
I'm always weary of leaving unused stuff in, because some future dev may misunderstand its purpose and wreak havoc with it :-)
There was a problem hiding this comment.
OK, I'm happy to remove it.
2f07a7f to
c21c5c5
Compare
Remove `@elidable` from abstract methods in tests, improve the error message. Also improve the scaladoc on `@elidable`.
c21c5c5 to
f1e5d65
Compare
| @@ -0,0 +1,6 @@ | |||
| object Test extends App { | |||
| def foo(): () => String = () => "hi there" | |||
| val f: () => Any = foo | |||
There was a problem hiding this comment.
Note that in 2.13 (-Xsource:2.13) this compiles without a warning, foo is applied to the empty parameter list.
In 2.12, eta-expansion comes in before, and it compiles with a deprecation warning:
➜ sandbox git:(syntacticNamedArgs-213) scalac Test.scala -deprecation
Test.scala:3: warning: Eta-expansion of zero-argument method values is deprecated. Did you intend to write Test.this.foo()?
val f: () => Any = foo
^
one warning found
So the program compiles in both versions, but differently.
Nullary methods are no longer eta-expanded. Assignments in paramter position need to be wrapped in brackets.
f1e5d65 to
03becd5
Compare
Adjust tests as necessary. Remove run test for t10097, it produces a compiler error under Xsource:2.13. This is tested in a neg test.
03becd5 to
b984e99
Compare
An `x = e` expression in parameter position is now a named argument, syntactically, unconditionally. Fixes scala/scala-dev#426
b984e99 to
926dbef
Compare
|
Sorry for the delay, Lukas. |
|
This merge broke the build, as noted in #6143 (comment) These are most likely the relevant commits that went into 2.13.x after this PRs parent: |
In scala#6092, `-Xsource:2.13` was enabled by default. Between this PRs parent and current 2.13.x, there were some changes that depended on this flag (scala#5983, scala#6069).
- scala/bug#5638 was fixed by something farther back than I can build. - scala/bug#8348 was fixed by scala#5251. - scala/bug#9291 was fixed by scala#6092.
-Xsource:2.13 by default)
An
x = eexpression in parameter position is now a named argument,syntactically, unconditionally.
Fixes scala/scala-dev#426