Skip to content

Commit

Permalink
Add test cases for #22103
Browse files Browse the repository at this point in the history
  • Loading branch information
Linyxus committed Jan 1, 2025
1 parent 001901d commit 32e550b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/pos-custom-args/captures/i22103-alt.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import language.experimental.captureChecking
import caps.*

trait F[+Cap^]
def expect[C^](x: F[C]): x.type = x

def test[C^](x: F[C], io: () => Unit): Unit =
val t1 = expect[CapSet^{C^}](x)
15 changes: 15 additions & 0 deletions tests/pos-custom-args/captures/i22103.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import language.experimental.captureChecking
import caps.*

abstract class Source[+T, Cap^]:
def transformValuesWith[U](f: (T -> U)^{Cap^}): Source[U, Cap]^{this, f} = ???

def race[T, Cap^](sources: Source[T, Cap]^{Cap^}*): Source[T, Cap]^{Cap^} = ???

def either[T1, T2, Cap^](
//io: () => Unit,
src1: Source[T1, Cap]^{Cap^},
src2: Source[T2, Cap]^{Cap^}): Source[Either[T1, T2], Cap]^{Cap^} =
val left = src1.transformValuesWith(Left(_))
val right = src2.transformValuesWith(Right(_))
race[Either[T1, T2], CapSet^{Cap^}](left, right) // <- rejected

0 comments on commit 32e550b

Please sign in to comment.