Skip to content

Inconsistent comparison of types involving unions of singleton types with Nothing #11003

Closed
@prolativ

Description

@prolativ

Minimized code

object Foo

val intSuper = summon[(Int | Nothing) <:< Int]
val intSub = summon[Int <:< (Int | Nothing)]
val intEq = summon[Int =:= (Int | Nothing)]

val fooSuper = summon[(Foo.type | Nothing) <:< Foo.type]
val fooSub = summon[Foo.type <:< (Foo.type | Nothing)]
val fooEq = summon[Foo.type =:= (Foo.type | Nothing)]

val oneSuper = summon[(1 | Nothing) <:< 1]
val oneSub = summon[1 <:< (1 | Nothing)]
val oneEq = summon[1 =:= (1 | Nothing)]

Output

[error] 9 |val fooEq = summon[Foo.type =:= (Foo.type | Nothing)]
[error]   |                                                     ^
[error]   |                        Cannot prove that Foo.type =:= Foo.type | Nothing.
[error] 11 |val oneSuper = summon[(1 | Nothing) <:< 1]
[error]    |                                          ^
[error]    |                    Cannot prove that (1 : Int) | Nothing <:< (1 : Int).
[error] 13 |val oneEq = summon[1 =:= (1 | Nothing)]
[error]    |                                       ^
[error]    |                    Cannot prove that (1 : Int) =:= (1 : Int) | Nothing.

Expectation

This should compile.

This bug might be the reason of #10897

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions