@@ -43,8 +43,8 @@ import dotty.tools.backend.jvm.DottyBackendInterface.symExtensions
4343 */
4444object JSEncoding {
4545
46- private val ScalaNothingClassName = ClassName (" scala.Nothing" )
47- private val ScalaNullClassName = ClassName (" scala.Null" )
46+ private val ScalaRuntimeNothingClassName = ClassName (" scala.runtime. Nothing$ " )
47+ private val ScalaRuntimeNullClassName = ClassName (" scala.runtime. Null$ " )
4848
4949 // Fresh local name generator ----------------------------------------------
5050
@@ -208,9 +208,9 @@ object JSEncoding {
208208 /** Computes the type ref for a type, to be used in a method signature. */
209209 private def paramOrResultTypeRef (tpe : Type )(using Context ): jstpe.TypeRef = {
210210 toTypeRef(tpe) match {
211- case jstpe.ClassRef (ScalaNullClassName ) => jstpe.NullRef
212- case jstpe.ClassRef (ScalaNothingClassName ) => jstpe.NothingRef
213- case otherTypeRef => otherTypeRef
211+ case jstpe.ClassRef (ScalaRuntimeNullClassName ) => jstpe.NullRef
212+ case jstpe.ClassRef (ScalaRuntimeNothingClassName ) => jstpe.NothingRef
213+ case otherTypeRef => otherTypeRef
214214 }
215215 }
216216
@@ -243,14 +243,20 @@ object JSEncoding {
243243 if (sym.isAllOf(ModuleClass | JavaDefined )) sym.linkedClass
244244 else sym
245245
246- if (sym1 == defn.BoxedUnitClass ) {
247- /* Rewire scala.runtime.BoxedUnit to java.lang.Void, as the IR expects.
248- * BoxedUnit$ is a JVM artifact.
249- */
246+ /* Some rewirings:
247+ * - scala.runtime.BoxedUnit to java.lang.Void, as the IR expects.
248+ * BoxedUnit$ is a JVM artifact.
249+ * - scala.Nothing to scala.runtime.Nothing$.
250+ * - scala.Null to scala.runtime.Null$.
251+ */
252+ if (sym1 == defn.BoxedUnitClass )
250253 ir.Names .BoxedUnitClass
251- } else {
254+ else if (sym1 == defn.NothingClass )
255+ ScalaRuntimeNothingClassName
256+ else if (sym1 == defn.NullClass )
257+ ScalaRuntimeNullClassName
258+ else
252259 ClassName (sym1.javaClassName)
253- }
254260 }
255261
256262 def toIRType (tp : Type )(using Context ): jstpe.Type = {
0 commit comments