Skip to content
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

Subtyping failure involving ExprType and unions of singleton types #8084

Closed
OlivierBlanvillain opened this issue Jan 23, 2020 · 1 comment
Closed

Comments

@OlivierBlanvillain
Copy link
Contributor

OlivierBlanvillain commented Jan 23, 2020

object Test {
  def foo(x: 0 | 1) = ()
  def bar: 0 | 1 = 0
  foo(bar)
}

Fails with:

4 |  foo(bar)                
  |      ^^^                 
  |      Found:    (Test.bar : => (0 : Int) | (1 : Int))  
  |      Required: (0 : Int) | (1 : Int)                  

Here are the relevant part of the logs with trancing enabled, it looks like there might be a missing case missing in type comparer?:

==> isSubType (Test.bar : => (0 : Int) | (1 : Int)) <:< (0 : Int) | (1 : Int) ?
  ==> isSubType (Test.bar : => (0 : Int) | (1 : Int)) <:< Nothing ?
    ==> isSubType => (0 : Int) | (1 : Int) <:< Nothing LoApprox?
    <== isSubType => (0 : Int) | (1 : Int) <:< Nothing LoApprox = false
  <== isSubType (Test.bar : => (0 : Int) | (1 : Int)) <:< Nothing  = false
<== isSubType (Test.bar : => (0 : Int) | (1 : Int)) <:< (0 : Int) | (1 : Int)  = false
@OlivierBlanvillain OlivierBlanvillain changed the title Missing case in type comparer Subtyping with unions of singleton types Jan 23, 2020
@smarter
Copy link
Member

smarter commented Jan 26, 2020

The following works:

object Test {
  def foo(x: 0 | 1) = ()
  def bar(): 0 | 1 = 0
  foo(bar())
}

So it's probably an issue with the subtyping checks involving ExprType on the left

@smarter smarter changed the title Subtyping with unions of singleton types Subtyping failure involving ExprType and unions of singleton types Jan 26, 2020
OlivierBlanvillain added a commit that referenced this issue Jan 29, 2020
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