-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Backports #19726 to the LTS branch. PR submitted by the release tooling. [skip ci]
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- [E103] Syntax Error: tests/neg/19087.scala:4:2 ---------------------------------------------------------------------- | ||
4 | Option.when(state.x == 0) body // error: Illegal start of toplevel definition | ||
| ^^^^^^ | ||
| Illegal start of toplevel definition | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E040] Syntax Error: tests/neg/19087.scala:15:6 --------------------------------------------------------------------- | ||
15 | bar = 2 // error: ',' or ')' expected | ||
| ^^^ | ||
| ',' or ')' expected, but identifier found | ||
-- [E067] Syntax Error: tests/neg/19087.scala:3:4 ---------------------------------------------------------------------- | ||
3 |def foo[T](state: State)(body: => T): Option[T] // error: only classes can have declared but undefined members | ||
| ^ | ||
| Declaration of method foo not allowed here: only classes can have declared but undefined members | ||
-- [E050] Type Error: tests/neg/19087.scala:13:22 ---------------------------------------------------------------------- | ||
13 | foo(state.copy(x = 5): // Missing ")" // error: method copy in class State does not take more parameters | ||
| ^^^^^^^^^^^^^^^^^ | ||
| method copy in class State does not take more parameters | ||
| | ||
| longer explanation available when compiling with `-explain` |
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,15 @@ | ||
case class State(x: Int) | ||
|
||
def foo[T](state: State)(body: => T): Option[T] // error: only classes can have declared but undefined members | ||
Option.when(state.x == 0) body // error: Illegal start of toplevel definition | ||
|
||
var bar = 0 | ||
val state = State(0) | ||
|
||
def app: Function1[Int, Unit] = | ||
new Function1[Int, Unit]: | ||
def apply(x: Int): Unit = | ||
foo(state): | ||
foo(state.copy(x = 5): // Missing ")" // error: method copy in class State does not take more parameters | ||
println("a") | ||
bar = 2 // error: ',' or ')' expected |