Closed
Description
I found two new problems after the fixes in #7835 for the previous issue #7807; opening a new issue here for @OlivierBlanvillain to fix, as suggested by @odersky.
minimized code
object Test2 with
type Flip[N <: 0 | 1] <: 0 | 1 = N match { case 0 => 1 case 1 => 0 }
def flip: (x: 0 | 1) => Flip[x.type] = ???
flip(0): 1 // ! does not type check
flip(1): 0
object Test3 with
type Flip[N <: 0 | 1] <: 0 | 1 = N match { case 0 => 1 case 1 => 0 }
def flip(x: 0 | 1): Flip[x.type] = ???
flip(0): 1 // ! causes: pickling difference for module class Test2$ in tests/pos/i7807.scala
flip(1): 0
Note that the following works:
object Test with
def flip: (x: 0 | 1) => x.type match { case 0 => 1 case 1 => 0 } = ???
flip(0): 1
flip(1): 0
flip(if ??? then 0 else 1)
val n: 0 | 1 = if ??? then 0 else 1
flip(n)
val m: n.type match { case 0 => 1 case 1 => 0 } = flip(n)