-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pattern match support in checking global objects (#18127)
Pattern match in checking global objects
- Loading branch information
Showing
14 changed files
with
322 additions
and
31 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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
object A { // error | ||
val n: Int = B.m | ||
class Inner { | ||
println(n) | ||
println(n) // error | ||
} | ||
} | ||
|
||
|
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,11 @@ | ||
-- Error: tests/init-global/neg/patmat-unapplySeq.scala:8:32 ----------------------------------------------------------- | ||
8 | def apply(i: Int): Box = array(i) // error | ||
| ^^^^^^^^ | ||
|Reading mutable state of object A during initialization of object B. | ||
|Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: | ||
|-> object B: [ patmat-unapplySeq.scala:15 ] | ||
| ^ | ||
|-> case A(b) => [ patmat-unapplySeq.scala:17 ] | ||
| ^^^^ | ||
|-> def apply(i: Int): Box = array(i) // error [ patmat-unapplySeq.scala:8 ] | ||
| ^^^^^^^^ |
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,17 @@ | ||
object A: | ||
class Box(var x: Int) | ||
|
||
val array: Array[Box] = new Array(1) | ||
array(0) = new Box(10) | ||
|
||
def length: Int = array.length | ||
def apply(i: Int): Box = array(i) // error | ||
def drop(n: Int): Seq[Box] = array.toSeq | ||
def toSeq: Seq[Box] = array.toSeq | ||
|
||
def unapplySeq(array: Array[Box]): A.type = this | ||
|
||
|
||
object B: | ||
A.array match | ||
case A(b) => |
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,17 @@ | ||
object A: | ||
class Box(var x: Int) | ||
|
||
val array: Array[Box] = new Array(1) | ||
array(0) = new Box(10) | ||
|
||
def length: Int = array.length | ||
def apply(i: Int): Box = array(i) // error | ||
def drop(n: Int): Seq[Box] = array.toSeq | ||
def toSeq: Seq[Box] = array.toSeq | ||
|
||
def unapplySeq(array: Array[Box]): A.type = this | ||
|
||
|
||
object B: | ||
A.array match | ||
case A(b*) => |
Oops, something went wrong.