Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unwiden scrutinee types, fixing match analysis
- Loading branch information
Showing
4 changed files
with
53 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
15: Pattern Match Exhaustivity: Thu, Fri |
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,18 @@ | ||
class C { | ||
val bool: true = true | ||
val not1: None.type = None | ||
|
||
def t1 = true match { case true => "inline true" } | ||
def t2 = bool match { case true => "valdef true" } | ||
def t3 = None match { case None => "inline None" } | ||
def t4 = not1 match { case None => "valdef None" } | ||
|
||
val monday: Day.Mon.type = Day.Mon | ||
val someday: Day = Day.Mon | ||
|
||
def t5 = Day.Mon match { case Day.Mon => 1 case Day.Tue => 2 case Day.Wed => 3 } | ||
def t6 = monday match { case Day.Mon => 1 case Day.Tue => 2 case Day.Wed => 3 } | ||
def t7 = someday match { case Day.Mon => 1 case Day.Tue => 2 case Day.Wed => 3 } | ||
} | ||
|
||
enum Day { case Mon, Tue, Wed, Thu, Fri } |
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,10 @@ | ||
class C { | ||
def m(x: true) = x match { // was: match may not be exhaustive.\nIt would fail on pattern case: false | ||
case true => println("the one true path") | ||
} | ||
|
||
def n(x: true) = x match { | ||
case true => 1 | ||
case false => 2 // was: no reachability warning on this case | ||
} | ||
} |