File tree Expand file tree Collapse file tree 4 files changed +10
-72
lines changed Expand file tree Collapse file tree 4 files changed +10
-72
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,8 @@ final class JSDefinitions()(using Context) {
6969 @ threadUnsafe lazy val PseudoUnion_fromTypeConstructorR = PseudoUnionModule .requiredMethodRef(" fromTypeConstructor" )
7070 def PseudoUnion_fromTypeConstructor (using Context ) = PseudoUnion_fromTypeConstructorR .symbol
7171
72+ @ threadUnsafe lazy val UnionOpsModuleRef = requiredModuleRef(" scala.scalajs.js.internal.UnitOps" )
73+
7274 @ threadUnsafe lazy val JSArrayType : TypeRef = requiredClassRef(" scala.scalajs.js.Array" )
7375 def JSArrayClass (using Context ) = JSArrayType .symbol.asClass
7476 @ threadUnsafe lazy val JSDynamicType : TypeRef = requiredClassRef(" scala.scalajs.js.Dynamic" )
Original file line number Diff line number Diff line change @@ -738,6 +738,13 @@ trait ImplicitRunInfo:
738738 .suchThat(companion => companion.is(Module ) && companion.owner == sym.owner)
739739 .symbol)
740740
741+ // The companion of `js.|` defines an implicit conversions from
742+ // `A | Unit` to `js.UndefOrOps[A]`. To keep this conversion in scope
743+ // in Scala 3, where we re-interpret `js.|` as a real union, we inject
744+ // it in the scope of `Unit`.
745+ if t.isRef(defn.UnitClass ) && ctx.settings.scalajs.value then
746+ companions += JSDefinitions .jsdefn.UnionOpsModuleRef
747+
741748 if sym.isClass then
742749 for p <- t.parents do companions ++= iscopeRefs(p)
743750 else
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ package scala.scalajs.js.internal
22
33import scala .scalajs .js
44
5- @ deprecated(message = " The implicit conversion was moved to the companion object of `scala.Unit` in Scala.js " , since = " 3.8.0 " )
5+ /** Under -scalajs, this object is part of the implicit scope of `scala.Unit` */
66object UnitOps :
77 implicit def unitOrOps [A ](x : A | Unit ): js.UndefOrOps [A ] =
88 new js.UndefOrOps (x)
You can’t perform that action at this time.
0 commit comments