Skip to content

Commit

Permalink
Test case
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Sep 25, 2022
1 parent b1b1dfd commit 6b1eda3
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/neg/i16095.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package x

import scala.annotation.*
import scala.concurrent.*

@capability
class CpsTransform[F[_]] {
def await[T](ft: F[T]): { this } T = ???
}

inline def cpsAsync[F[_]] =
Test.InfernAsyncArg
object Test {

class InfernAsyncArg[F[_]] {
def apply[A](expr: CpsTransform[F] ?=> A): F[A] = ???
}

def asyncPlus[F[_]](a:Int, b:F[Int])(using cps: CpsTransform[F]): { cps } Int =
a + cps.await(b)

def testExample1Future(): Unit =
val fr = cpsAsync[Future] {
val y = asyncPlus(1,Future successful 2)
y+1
}
val r = Await.result(fr)
assert(r == Success(3))

}

0 comments on commit 6b1eda3

Please sign in to comment.