Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/backend/sjs/JSDefinitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ final class JSDefinitions()(using Context) {
@threadUnsafe lazy val PseudoUnion_fromTypeConstructorR = PseudoUnionModule.requiredMethodRef("fromTypeConstructor")
def PseudoUnion_fromTypeConstructor(using Context) = PseudoUnion_fromTypeConstructorR.symbol

@threadUnsafe lazy val UnionOpsModuleRef = requiredModuleRef("scala.scalajs.js.internal.UnitOps")

@threadUnsafe lazy val JSArrayType: TypeRef = requiredClassRef("scala.scalajs.js.Array")
def JSArrayClass(using Context) = JSArrayType.symbol.asClass
@threadUnsafe lazy val JSDynamicType: TypeRef = requiredClassRef("scala.scalajs.js.Dynamic")
Expand Down
7 changes: 7 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,13 @@ trait ImplicitRunInfo:
.suchThat(companion => companion.is(Module) && companion.owner == sym.owner)
.symbol)

// The companion of `js.|` defines an implicit conversions from
// `A | Unit` to `js.UndefOrOps[A]`. To keep this conversion in scope
// in Scala 3, where we re-interpret `js.|` as a real union, we inject
// it in the scope of `Unit`.
if t.isRef(defn.UnitClass) && ctx.settings.scalajs.value then
companions += JSDefinitions.jsdefn.UnionOpsModuleRef

if sym.isClass then
for p <- t.parents do companions ++= iscopeRefs(p)
else
Expand Down
71 changes: 0 additions & 71 deletions library-js/src/scala/Unit.scala

This file was deleted.

2 changes: 1 addition & 1 deletion library-js/src/scala/scalajs/js/internal/UnitOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package scala.scalajs.js.internal

import scala.scalajs.js

@deprecated(message = "The implicit conversion was moved to the companion object of `scala.Unit` in Scala.js", since = "3.8.0")
/** Under -scalajs, this object is part of the implicit scope of `scala.Unit` */
object UnitOps:
implicit def unitOrOps[A](x: A | Unit): js.UndefOrOps[A] =
new js.UndefOrOps(x)
Loading