Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Synthesizer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
val monoTypeDef = untpd.TypeDef(tpnme.MirroredMonoType, untpd.TypeTree(monoType))
val newImpl = untpd.Template(
constr = untpd.emptyConstructor,
parents = untpd.TypeTree(defn.ObjectType) :: Nil,
parents = untpd.TypeTree(defn.ObjectType) :: untpd.TypeTree(defn.JavaSerializableClass.typeRef) :: Nil,
derived = Nil,
self = EmptyValDef,
body = monoTypeDef :: Nil
Expand Down
9 changes: 9 additions & 0 deletions tests/run/serialize.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ object Test {
}
}

// No Companion defined - therefore anonmymous mirror is generated
sealed trait NoCompanion
case class Value(value: String) extends NoCompanion

def main(args: Array[String]): Unit = {
val x: PartialFunction[Int, Int] = { case x => x + 1 }
val adder = serializeDeserialize(x)
Expand All @@ -41,5 +45,10 @@ object Test {
val bar = new a.Bar
val bar1 = serializeDeserialize(bar)
assert(bar.x eq bar1.x)

val mirror = summon[scala.deriving.Mirror.Of[NoCompanion]]
val mirror1 = serializeDeserialize(mirror)
assert(mirror ne mirror1) // update if we start caching anonymous mirrors
assert(mirror1.ordinal(Value("")) == 0) // check API
}
}