diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index 5df373a01e4a..612a5ce86e21 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -210,6 +210,8 @@ class Definitions { cls } @tu lazy val ScalaPackageObject: Symbol = requiredModule("scala.package") + @tu lazy val ScalaRuntimePackageVal: TermSymbol = requiredPackage("scala.runtime") + @tu lazy val ScalaRuntimePackageClass: ClassSymbol = ScalaRuntimePackageVal.moduleClass.asClass @tu lazy val JavaPackageVal: TermSymbol = requiredPackage(nme.java) @tu lazy val JavaPackageClass: ClassSymbol = JavaPackageVal.moduleClass.asClass @tu lazy val JavaLangPackageVal: TermSymbol = requiredPackage(jnme.JavaLang) @@ -1098,6 +1100,9 @@ class Definitions { def isTupleClass(cls: Symbol): Boolean = isVarArityClass(cls, str.Tuple) def isProductClass(cls: Symbol): Boolean = isVarArityClass(cls, str.Product) + def isBoxedUnitClass(cls: Symbol): Boolean = + cls.isClass && (cls.owner eq ScalaRuntimePackageClass) && cls.name == tpnme.BoxedUnit + def isScalaShadowingPackageClass(cls: Symbol): Boolean = cls.name == tpnme.scalaShadowing && cls.owner == RootClass @@ -1314,6 +1319,11 @@ class Definitions { else parents } + /** 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/StdNames.scala b/compiler/src/dotty/tools/dotc/core/StdNames.scala index 87a1b6e25161..04b2bfdc74fb 100644 --- a/compiler/src/dotty/tools/dotc/core/StdNames.scala +++ b/compiler/src/dotty/tools/dotc/core/StdNames.scala @@ -306,6 +306,7 @@ object StdNames { final val Nil: N = "Nil" final val Predef: N = "Predef" final val ScalaRunTime: N = "ScalaRunTime" + final val BoxedUnit: N = "BoxedUnit" final val Some: N = "Some" val x_0 : N = "x$0" diff --git a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala index 0cb50e868d01..17f6731ffe49 100644 --- a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala @@ -98,10 +98,11 @@ object Scala2Unpickler { val tempInfo = new TempClassInfo(denot.owner.thisType, cls, decls, ost) denot.info = tempInfo // first rough info to avoid CyclicReferences val parents1 = if (parents.isEmpty) defn.ObjectType :: Nil else parents.map(_.dealias) - // Add extra parents to the tuple classes from the standard library + // Adjust parents of the tuple classes and BoxedUnit from the standard library + // 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 parents1 // We are setting the info of a Java class, so it cannot be one of the tuple classes + else defn.adjustForBoxedUnit(cls, 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 c1afdb22b08d..f488c417d049 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -1170,7 +1170,10 @@ class Namer { typer: Typer => denot.info = tempInfo val parentTypes = defn.adjustForTuple(cls, cls.typeParams, - ensureFirstIsClass(parents.map(checkedParentType(_)), cls.span)) + defn.adjustForBoxedUnit(cls, + ensureFirstIsClass(parents.map(checkedParentType(_)), cls.span) + ) + ) typr.println(i"completing $denot, parents = $parents%, %, parentTypes = $parentTypes%, %") if (impl.derived.nonEmpty) { diff --git a/project/Build.scala b/project/Build.scala index 3003c44fff74..dd5b55871190 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1054,7 +1054,7 @@ object Build { ++ (dir / "shared/src/test/scala/org/scalajs/testsuite/utils" ** "*.scala").get ++ (dir / "shared/src/test/scala/org/scalajs/testsuite/junit" ** "*.scala").get ++ (dir / "shared/src/test/scala/org/scalajs/testsuite/niobuffer" ** "*.scala").get - ++ (dir / "shared/src/test/scala/org/scalajs/testsuite/niocharset" ** (("*.scala": FileFilter) -- "BaseCharsetTest.scala" -- "Latin1Test.scala" -- "USASCIITest.scala" -- "UTF16Test.scala" -- "UTF8Test.scala")).get + ++ (dir / "shared/src/test/scala/org/scalajs/testsuite/niocharset" ** "*.scala").get ++ (dir / "shared/src/test/scala/org/scalajs/testsuite/scalalib" ** (("*.scala": FileFilter) -- "EnumerationTest.scala" -- "SymbolTest.scala")).get ++ (dir / "shared/src/test/require-sam" ** "*.scala").get ++ (dir / "shared/src/test/require-jdk8/org/scalajs/testsuite/compiler" ** "*.scala").get