@@ -43,8 +43,8 @@ import dotty.tools.backend.jvm.DottyBackendInterface.symExtensions
43
43
*/
44
44
object JSEncoding {
45
45
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$ " )
48
48
49
49
// Fresh local name generator ----------------------------------------------
50
50
@@ -208,9 +208,9 @@ object JSEncoding {
208
208
/** Computes the type ref for a type, to be used in a method signature. */
209
209
private def paramOrResultTypeRef (tpe : Type )(using Context ): jstpe.TypeRef = {
210
210
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
214
214
}
215
215
}
216
216
@@ -243,14 +243,20 @@ object JSEncoding {
243
243
if (sym.isAllOf(ModuleClass | JavaDefined )) sym.linkedClass
244
244
else sym
245
245
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 )
250
253
ir.Names .BoxedUnitClass
251
- } else {
254
+ else if (sym1 == defn.NothingClass )
255
+ ScalaRuntimeNothingClassName
256
+ else if (sym1 == defn.NullClass )
257
+ ScalaRuntimeNullClassName
258
+ else
252
259
ClassName (sym1.javaClassName)
253
- }
254
260
}
255
261
256
262
def toIRType (tp : Type )(using Context ): jstpe.Type = {
0 commit comments