File tree Expand file tree Collapse file tree 4 files changed +25
-1
lines changed
scala-new-collections/scala/scalajs/js
scala-old-collections/scala/scalajs/js
sbt-plugin/src/sbt-test/scala3/basic Expand file tree Collapse file tree 4 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,16 @@ object Any extends LowPrioAnyImplicits {
79
79
@ inline implicit def fromString (s : String ): js.Any =
80
80
s.asInstanceOf [js.Any ]
81
81
82
+ /* This one is not very "in the spirit" of the union type, but it used to be
83
+ * available for `js.UndefOr[A]`, so we keep it for backward source
84
+ * compatibility. It is not really harmful, and has some perks in certain
85
+ * interoperability scenarios.
86
+ */
87
+ implicit def undefOr2jsAny [A ](value : js.UndefOr [A ])(
88
+ implicit ev : A => js.Any ): js.Any = {
89
+ value.map(ev).asInstanceOf [js.Any ]
90
+ }
91
+
82
92
/* The following overload makes sure that the developer does not
83
93
* inadvertently convert a Long to a Double to fit it in a js.Any.
84
94
*/
Original file line number Diff line number Diff line change @@ -77,6 +77,16 @@ object Any extends js.LowPrioAnyImplicits {
77
77
@ inline implicit def fromString (s : String ): js.Any =
78
78
s.asInstanceOf [js.Any ]
79
79
80
+ /* This one is not very "in the spirit" of the union type, but it used to be
81
+ * available for `js.UndefOr[A]`, so we keep it for backward source
82
+ * compatibility. It is not really harmful, and has some perks in certain
83
+ * interoperability scenarios.
84
+ */
85
+ implicit def undefOr2jsAny [A ](value : js.UndefOr [A ])(
86
+ implicit ev : A => js.Any ): js.Any = {
87
+ value.map(ev).asInstanceOf [js.Any ]
88
+ }
89
+
80
90
/* The following overload makes sure that the developer does not
81
91
* inadvertently convert a Long to a Double to fit it in a js.Any.
82
92
*/
Original file line number Diff line number Diff line change @@ -113,7 +113,8 @@ object | { // scalastyle:ignore
113
113
* compatibility. It is not really harmful, and has some perks in certain
114
114
* interoperability scenarios.
115
115
*/
116
- implicit def undefOr2jsAny [A ](value : js.UndefOr [A ])(
116
+ @ deprecated(" Relocated to js.Any.undefOr2jsAny" , " 1.14.0" )
117
+ def undefOr2jsAny [A ](value : js.UndefOr [A ])(
117
118
implicit ev : A => js.Any ): js.Any = {
118
119
value.map(ev).asInstanceOf [js.Any ]
119
120
}
Original file line number Diff line number Diff line change @@ -22,5 +22,8 @@ object Main {
22
22
23
23
// Testing the library resolved with %%% + withDottyCompat
24
24
assert(Types .IntType .show() == " int" )
25
+
26
+ // Testing the undefOr2jsAny implicit conversion
27
+ val x : js.Any = js.defined(" " )
25
28
}
26
29
}
You can’t perform that action at this time.
0 commit comments