Skip to content

Subtyping failure involving ExprType and unions of singleton types #8084

Closed
@OlivierBlanvillain

Description

@OlivierBlanvillain
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions