Skip to content

Commit 89a68b5

Browse files
Merge pull request #8106 from travisbrown/topic/case-object-derives
Fix #8105: Make check aware of case objects
2 parents c4a3de4 + 31efc7b commit 89a68b5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ trait Implicits { self: Typer =>
909909
/** A path referencing the companion of class type `clsType` */
910910
private def companionPath(clsType: Type, span: Span)(implicit ctx: Context) = {
911911
val ref = pathFor(clsType.companionRef)
912-
assert(ref.symbol.is(Module) && ref.symbol.companionClass == clsType.classSymbol)
912+
assert(ref.symbol.is(Module) && (clsType.classSymbol.is(ModuleClass) || (ref.symbol.companionClass == clsType.classSymbol)))
913913
ref.withSpan(span)
914914
}
915915

tests/run/typeclass-derivation3.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ object datatypes {
1919
sealed trait Either[+L, +R] extends Product with Serializable derives Eq, Pickler, Show
2020
case class Left[L](x: L) extends Either[L, Nothing]
2121
case class Right[R](x: R) extends Either[Nothing, R]
22+
23+
// a case object
24+
case object Thing derives Eq, Pickler, Show
2225
}
2326

2427
object typeclasses {

0 commit comments

Comments
 (0)