From 32e550b0a4515f6f477146b3653f6ac84eb9dca4 Mon Sep 17 00:00:00 2001 From: Yichen Xu Date: Wed, 1 Jan 2025 17:01:32 +0000 Subject: [PATCH] Add test cases for #22103 --- tests/pos-custom-args/captures/i22103-alt.scala | 8 ++++++++ tests/pos-custom-args/captures/i22103.scala | 15 +++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/pos-custom-args/captures/i22103-alt.scala create mode 100644 tests/pos-custom-args/captures/i22103.scala diff --git a/tests/pos-custom-args/captures/i22103-alt.scala b/tests/pos-custom-args/captures/i22103-alt.scala new file mode 100644 index 000000000000..c08c6b5a4e4d --- /dev/null +++ b/tests/pos-custom-args/captures/i22103-alt.scala @@ -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) diff --git a/tests/pos-custom-args/captures/i22103.scala b/tests/pos-custom-args/captures/i22103.scala new file mode 100644 index 000000000000..a3c7bfe57251 --- /dev/null +++ b/tests/pos-custom-args/captures/i22103.scala @@ -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