diff --git a/compiler/src/dotty/tools/backend/sjs/JSEncoding.scala b/compiler/src/dotty/tools/backend/sjs/JSEncoding.scala index a097c4ca5a8b..6b44dd48ee7e 100644 --- a/compiler/src/dotty/tools/backend/sjs/JSEncoding.scala +++ b/compiler/src/dotty/tools/backend/sjs/JSEncoding.scala @@ -43,8 +43,8 @@ import dotty.tools.backend.jvm.DottyBackendInterface.symExtensions */ object JSEncoding { - private val ScalaNothingClassName = ClassName("scala.Nothing") - private val ScalaNullClassName = ClassName("scala.Null") + private val ScalaRuntimeNothingClassName = ClassName("scala.runtime.Nothing$") + private val ScalaRuntimeNullClassName = ClassName("scala.runtime.Null$") // Fresh local name generator ---------------------------------------------- @@ -208,9 +208,9 @@ object JSEncoding { /** Computes the type ref for a type, to be used in a method signature. */ private def paramOrResultTypeRef(tpe: Type)(using Context): jstpe.TypeRef = { toTypeRef(tpe) match { - case jstpe.ClassRef(ScalaNullClassName) => jstpe.NullRef - case jstpe.ClassRef(ScalaNothingClassName) => jstpe.NothingRef - case otherTypeRef => otherTypeRef + case jstpe.ClassRef(ScalaRuntimeNullClassName) => jstpe.NullRef + case jstpe.ClassRef(ScalaRuntimeNothingClassName) => jstpe.NothingRef + case otherTypeRef => otherTypeRef } } @@ -243,14 +243,20 @@ object JSEncoding { if (sym.isAllOf(ModuleClass | JavaDefined)) sym.linkedClass else sym - if (sym1 == defn.BoxedUnitClass) { - /* Rewire scala.runtime.BoxedUnit to java.lang.Void, as the IR expects. - * BoxedUnit$ is a JVM artifact. - */ + /* Some rewirings: + * - scala.runtime.BoxedUnit to java.lang.Void, as the IR expects. + * BoxedUnit$ is a JVM artifact. + * - scala.Nothing to scala.runtime.Nothing$. + * - scala.Null to scala.runtime.Null$. + */ + if (sym1 == defn.BoxedUnitClass) ir.Names.BoxedUnitClass - } else { + else if (sym1 == defn.NothingClass) + ScalaRuntimeNothingClassName + else if (sym1 == defn.NullClass) + ScalaRuntimeNullClassName + else ClassName(sym1.javaClassName) - } } def toIRType(tp: Type)(using Context): jstpe.Type = { diff --git a/project/Build.scala b/project/Build.scala index 4b6db5d8471e..d751819c8e47 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1055,7 +1055,7 @@ object Build { ++ (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/scalalib" ** (("*.scala": FileFilter) -- "ArrayBuilderTest.scala" -- "ClassTagTest.scala" -- "EnumerationTest.scala" -- "SymbolTest.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": FileFilter) -- "DefaultMethodsTest.scala")).get ++ (dir / "shared/src/test/require-jdk8/org/scalajs/testsuite/javalib/lang" ** "*.scala").get