From b73b1ab685b09baa77d752f1f52ec5a5b4221c4a Mon Sep 17 00:00:00 2001 From: Hamza Remmal Date: Sun, 7 Dec 2025 02:34:32 +0100 Subject: [PATCH] chore: do not patch `BoxedUnit` anymore --- compiler/src/dotty/tools/dotc/core/Definitions.scala | 5 ----- .../tools/dotc/core/unpickleScala2/Scala2Unpickler.scala | 2 +- compiler/src/dotty/tools/dotc/typer/Namer.scala | 8 +++----- library/src/scala/runtime/BoxedUnit.java | 6 +----- 4 files changed, 5 insertions(+), 16 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index 8d305eef16e1..ca4c40c4207b 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -1935,11 +1935,6 @@ class Definitions { TypeOps.nestedPairs(tparams.map(_.typeRef)) :: parents.tail } - /** If it is BoxedUnit, remove `java.io.Serializable` from `parents`. */ - def adjustForBoxedUnit(cls: ClassSymbol, parents: List[Type]): List[Type] = - if (isBoxedUnitClass(cls)) parents.filter(_.typeSymbol != JavaSerializableClass) - else parents - private val HasProblematicGetClass: Set[Name] = Set( tpnme.AnyVal, tpnme.Byte, tpnme.Short, tpnme.Char, tpnme.Int, tpnme.Long, tpnme.Float, tpnme.Double, tpnme.Unit, tpnme.Boolean) diff --git a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala index 630e618fa09d..fcb18c4148af 100644 --- a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala @@ -106,7 +106,7 @@ object Scala2Unpickler { // If from Scala 2, adjust for tuple classes; if not, it's from Java, and adjust for BoxedUnit val normalizedParents = if (fromScala2) defn.adjustForTuple(cls, tparams, parents1) - else defn.adjustForBoxedUnit(cls, parents1) + else parents1 for (tparam <- tparams) { val tsym = decls.lookup(tparam.name) if (tsym.exists) tsym.setFlag(TypeParam) diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 82c25fbed242..455433c324ec 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -1749,11 +1749,9 @@ class Namer { typer: Typer => denot.info = tempInfo.nn val parentTypes = defn.adjustForTuple(cls, cls.typeParams, - defn.adjustForBoxedUnit(cls, - addUsingTraits: - val isJava = ctx.isJava - ensureFirstIsClass(cls, parents.map(checkedParentType(_, isJava))) - ) + addUsingTraits: + val isJava = ctx.isJava + ensureFirstIsClass(cls, parents.map(checkedParentType(_, isJava))) ) typr.println(i"completing $denot, parents = $parents%, %, parentTypes = $parentTypes%, %") diff --git a/library/src/scala/runtime/BoxedUnit.java b/library/src/scala/runtime/BoxedUnit.java index aaa986f87f1a..6189d997835c 100644 --- a/library/src/scala/runtime/BoxedUnit.java +++ b/library/src/scala/runtime/BoxedUnit.java @@ -12,15 +12,11 @@ package scala.runtime; - -public final class BoxedUnit implements java.io.Serializable { - private static final long serialVersionUID = 8405543498931817370L; +public final class BoxedUnit { public final static BoxedUnit UNIT = new BoxedUnit(); public final static Class TYPE = java.lang.Void.TYPE; - - private Object readResolve() { return UNIT; } private BoxedUnit() { }