Skip to content

Commit

Permalink
More regression tests
Browse files Browse the repository at this point in the history
Closes scala#9287
Closes scala#12640
Closes scala#12896
  • Loading branch information
odersky authored and michelou committed Apr 25, 2022
1 parent 133cb46 commit e3b652d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/neg/i12640.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package x

trait CpsMonad[F[_]]:
def pure[A](x:A): F[A]
def flatMap[A,B](fa:F[A])(f: A=>F[B]): F[B]

abstract sealed class CpsStream[-F[_],+T]

case class Cons[F[_],T](head:T, tailFun: ()=>F[CpsStream[F,T]]) extends CpsStream[F,T]

case class Empty[F[_]]() extends CpsStream[F,Nothing]

def unfold[S,F[_]:CpsMonad,T](s0:S)(f:S => F[Option[(S,T)]]):F[CpsStream[F,T]] =
summon[CpsMonad[F]].flatMap(f(s0)){
case Some(s1,a) => Cons(a, () => unfold(s1,f)) // error (used to crash)
case None => summon[CpsMonad[F]].pure(Empty[F]())
}
7 changes: 7 additions & 0 deletions tests/neg/i9287.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
object Foo {
Nil {
class i0 { a: i2 => // error
class i1
}
} // error
}
12 changes: 12 additions & 0 deletions tests/pos/i12896.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
trait IO[E] {
def map[B](f: Any => B): IO[E] = ???
def flatMap[C](f: Any => IO[C]): IO[E | C] = ???
}

class Test {
def test: Unit = {
val a: IO[Nothing] = ???

val d = a.flatMap(y => a.flatMap(z => a.map(_ => z)))
}
}

0 comments on commit e3b652d

Please sign in to comment.