Skip to content

Failed to derive mirror in trait with self type #18918

Closed
@Anghammar

Description

@Anghammar

Compiler version

3.3.0

Minimized code

trait SuperTrait {
  sealed trait InnerTrait
  case class Foo() extends InnerTrait
}

trait OtherTrait

trait TraitWithSelfType extends SuperTrait { this: OtherTrait =>
  summon[deriving.Mirror.Of[Foo]]
  summon[deriving.Mirror.Of[InnerTrait]]
}

object Implementation extends TraitWithSelfType, OtherTrait {
  summon[deriving.Mirror.Of[Foo]]
  summon[deriving.Mirror.Of[InnerTrait]]
}

Output

-- [E172] Type Error: DerivingMirrorBug:10:40 ----------------------------------
10 |  summon[deriving.Mirror.Of[InnerTrait]]
   |                                        ^
   |No given instance of type deriving.Mirror.Of[TraitWithSelfType.this.InnerTrait] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Of[TraitWithSelfType.this.InnerTrait]:
   |	* trait InnerTrait is not a generic product because it is not a case class
   |	* trait InnerTrait is not a generic sum because its child class Foo is not accessible to call site value <local TraitWithSelfType>
1 error found

Expectation

summon[deriving.Mirror.Of[InnerTrait]] fails inside of TraitWithSelfType, but no of the other three summons fails. I'm not 100% sure this is actually a bug, but since OtherTrait does not actually do anything it sure seems like it. If it in fact works as intended, I would appreciate a short explanation why.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions