-
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.
As usual, OrTypes need to be excluded. a.type | b.type is not effectively a singleton. It seems to be an easy trap to fall into. Follow-up to #20474
- Loading branch information
Showing
2 changed files
with
14 additions
and
2 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,13 @@ | ||
class A | ||
class B extends A | ||
|
||
def f(a: A, c: A) = | ||
val b1: a.type = a | ||
val b2: a.type & B = a.asInstanceOf[a.type & B] | ||
val b3: c.type & A = c | ||
val b4: a.type | c.type = c | ||
|
||
val d1: b1.type = a | ||
val d2: b2.type = a // ok | ||
val d3: b3.type = a // error | ||
val d4: b4.type = a // error |