Skip to content

No implicit Show for union of singleton types in REPL #4010

Closed
@senia-psm

Description

@senia-psm
scala> trait TmpT { type A; type B; type AorB = A | B ; def fromA(a: A): AorB = a; def fromB(b: B): AorB = b } 
// defined trait TmpT
scala> object TmpO extends TmpT{ type A = 7; type B = 8 } 
// defined object TmpO
scala> val x: TmpO.AorB = TmpO.fromA(7) 
1 |val x: TmpO.AorB = TmpO.fromA(7)
  |^
  |no implicit argument of type dotty.Show[TmpO.AorB] was found for parameter ev of method show in class ShowValue.
  |I found:
  |
  |    dotty.Show.defaultShow[Nothing]
  |
  |But method defaultShow in trait LowPrioShow does not match type dotty.Show[TmpO.AorB].

Note that one can fix it using this line:

implicit val showAorB: dotty.Show[TmpO.AorB] = dotty.Show.defaultShow[TmpO.AorB]

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