Commit f55d869
committed
Support Scala.js unions extra methods via implicit conversion
The companion of `js.|` contains the following widely used implicit
conversion to a value class:
/** Provides an [[Option]]-like API to [[js.UndefOr]]. */
implicit def undefOr2ops[A](value: js.UndefOr[A]): js.UndefOrOps[A] =
new js.UndefOrOps(value)
(where `UndefOr[A]` dealiases to `A | Unit`).
Since we re-interpret Scala.js unions as real unions, this companion is
not in the implicit scope of `A | Unit`, we work around this by
injecting a new `UnitOps` with the implicit conversion we want in the
implicit scope of `Unit` (we could have directly injected the object
`js.|`, but that contains other implicits we do not need).
This finally lets us compile and run the sjsJUnitTests after the
previous two commits.1 parent de1b04e commit f55d869
File tree
4 files changed
+20
-1
lines changed- compiler/src/dotty/tools
- backend/sjs
- dotc/typer
- library-js/src/scala/scalajs/js/internal
- project
4 files changed
+20
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
634 | 635 | | |
635 | 636 | | |
636 | 637 | | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
637 | 646 | | |
638 | 647 | | |
639 | 648 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
698 | 698 | | |
699 | 699 | | |
700 | 700 | | |
701 | | - | |
| 701 | + | |
702 | 702 | | |
703 | 703 | | |
704 | 704 | | |
| |||
0 commit comments