forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request scala#12925 from dotty-staging/fix-12909
Widen unions before finding members
- Loading branch information
Showing
3 changed files
with
63 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package example | ||
|
||
final case class Writer[W, A](run: (W, A)) { | ||
def map[B](f: A => B): Writer[W, B] = ??? | ||
|
||
def flatMap[B](f: A => Writer[W, B]): Writer[W, B] = ??? | ||
} | ||
|
||
object Main { | ||
implicit class WriterOps[A](a: A) { | ||
def set[W](w: W): Writer[W, A] = ??? | ||
} | ||
|
||
def x1[A]: Writer[Vector[String], Option[A]] = ??? | ||
|
||
val failure = for { | ||
a1 <- { | ||
Option(1) match { | ||
case Some(x) => | ||
x1[Boolean] | ||
case _ => | ||
Option.empty[Boolean].set(Vector.empty[String]) | ||
} | ||
} | ||
a2 <- x1[String] | ||
} yield () | ||
|
||
val success = for { | ||
a1 <- { | ||
val temp = Option(1) match { | ||
case Some(x) => | ||
x1[Boolean] | ||
case _ => | ||
Option.empty[Boolean].set(Vector.empty[String]) | ||
} | ||
// why ??? | ||
temp | ||
} | ||
a2 <- x1[String] | ||
} yield () | ||
|
||
} |