-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Pattern match support in checking global objects #18127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5b651b7
WIP - initial support for pattern matches
liufengyun b2a6be1
Complete the support for unapply
liufengyun d93a214
Move test to correct directory
liufengyun 6d645b7
Add support for unapplySeq
liufengyun 59e22a2
Add unapplySeq tests
liufengyun 29a350f
Address review
liufengyun 7406ddb
Fix crash
liufengyun a767c6b
Fix swallowing of warnings
liufengyun 4cfcacf
Fix tests after error reporting change
liufengyun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.