Skip to content

Bounds check failure involving unions of singleton types #8129

Closed
@OlivierBlanvillain

Description

@OlivierBlanvillain
object Test {
  type F[N <: 0 | 1] = N
  def fl[N <: 0 | 1]: F[N] = ???
}
-- [E057] Type Mismatch Error: /test.scala:3:24 
3 |  def fl[N <: 0 | 1]: F[N] = ???
  |                        ^
  |Type argument N does not conform to upper bound (0 : scala.Int) | (1 : scala.Int) 
==> isSubType N <:< (0 : scala.Int) | (1 : scala.Int) ?
  ==> isSubType N <:< scala.Nothing ?
    ==> isSubType (0 : scala.Int) | (1 : scala.Int) <:< scala.Nothing LoApprox?
      ==> isSubType scala.Int <:< scala.Nothing LoApprox?
      <== isSubType scala.Int <:< scala.Nothing LoApprox = false
      ==> isSubType (0 : scala.Int) <:< scala.Nothing LoApprox?
        ==> isSubType scala.Int <:< scala.Nothing LoApprox?
        <== isSubType scala.Int <:< scala.Nothing LoApprox = false
      <== isSubType (0 : scala.Int) <:< scala.Nothing LoApprox = false
    <== isSubType (0 : scala.Int) | (1 : scala.Int) <:< scala.Nothing LoApprox = false
  <== isSubType N <:< scala.Nothing  = false
<== isSubType N <:< (0 : scala.Int) | (1 : scala.Int)  = false

(I tought this was related to #8126, but it's something else)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions