Skip to content

Match types on singletons crash the compiler more #7872

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

Closed
LPTK opened this issue Dec 30, 2019 · 1 comment
Closed

Match types on singletons crash the compiler more #7872

LPTK opened this issue Dec 30, 2019 · 1 comment

Comments

@LPTK
Copy link
Contributor

LPTK commented Dec 30, 2019

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)
@OlivierBlanvillain
Copy link
Contributor

I futher minimised the type checking issue to #8128, which doesn't involve match types. The pickling issue is probably a duplicate of the ones we already have in pos-test-pickling.blacklist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants