-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SI-6771 Alias awareness for checkableType in match analysis.
Failure to dealias the type of the scrutinee led the pattern matcher to incorrectly reason about the type test in: type Id[X] = X; (null: Id[Option[Int]]) match { case Some(_) => } Before, `checkableType` returned `Id[?]`, now it returns `Some[?]`.
- Loading branch information
Showing
5 changed files
with
35 additions
and
1 deletion.
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,6 @@ | ||
t6771b.scala:14: error: type mismatch; | ||
found : x.type (with underlying type String) | ||
required: Test.a.type | ||
b = b match { case x => x } | ||
^ | ||
one error found |
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,16 @@ | ||
// Currently, the pattern matcher widens the type of the | ||
// scrutinee, so this doesn't typecheck. This test just | ||
// confirms this behaviour, although it would be an improvement | ||
// to change this and make this a `pos` test. | ||
// | ||
// But, to the intrepid hacker who works on this, a few notes: | ||
// You'll have to look into places in the pattern matcher that | ||
// call `dealias`, and see if they need to be `dealiasWiden`. | ||
// For example, if `checkableType` used only `dealias`, `pos/t6671.scala` | ||
// would fail. | ||
object Test { | ||
val a = ""; var b: a.type = a | ||
|
||
b = b match { case x => x } | ||
} | ||
|
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 @@ | ||
-Xfatal-warnings |
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,9 @@ | ||
object Test { | ||
type Id[X] = X | ||
val a: Id[Option[Int]] = None | ||
|
||
a match { | ||
case Some(x) => println(x) | ||
case None => | ||
} | ||
} |