diff --git a/tests/neg/i6565.scala b/tests/neg/i6565.scala new file mode 100644 index 000000000000..a51eeb24c308 --- /dev/null +++ b/tests/neg/i6565.scala @@ -0,0 +1,17 @@ +class Err + +type Lifted[A] = Err | A + +def point[O](o: O): Lifted[O] = o +def (o: Lifted[O]) map [O, U] (f: O => U): Lifted[U] = ??? +def (o: Lifted[O]) flatMap [O, U] (f: O => Lifted[U]): Lifted[U] = ??? + +val error: Err = Err() + +lazy val ok: Lifted[String] = { // ok despite map returning a union + point("a").map(_ => if true then "foo" else error) // error +} + +lazy val bad: Lifted[String] = { // found Lifted[Object] + point("a").flatMap(_ => point("b").map(_ => if true then "foo" else error)) // error +} \ No newline at end of file