From 20917c7a95f004ac5caad5097d5d06eb5120da77 Mon Sep 17 00:00:00 2001 From: noti0na1 Date: Tue, 19 Nov 2024 18:04:51 +0100 Subject: [PATCH] Add some tests --- .../captures/capset-bound.scala | 18 ++++++++++++++++++ tests/neg-custom-args/captures/i21868.scala | 14 ++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tests/neg-custom-args/captures/capset-bound.scala create mode 100644 tests/neg-custom-args/captures/i21868.scala diff --git a/tests/neg-custom-args/captures/capset-bound.scala b/tests/neg-custom-args/captures/capset-bound.scala new file mode 100644 index 000000000000..c00f61240dea --- /dev/null +++ b/tests/neg-custom-args/captures/capset-bound.scala @@ -0,0 +1,18 @@ +import caps.* + +class IO + +case class File(io: IO^) + +def test(io1: IO^, io2: IO^) = + def f[C >: CapSet^{io1} <: CapSet^](file: File^{C^}) = ??? + val f1: File^{io1} = ??? + val f2: File^{io2} = ??? + val f3: File^{io1, io2} = ??? + f[CapSet^{io1}](f1) + f[CapSet^{io1}](f2) // error + f[CapSet^{io1}](f3) // error + f[CapSet^{io2}](f2) // error + f[CapSet^{io1, io2}](f1) + f[CapSet^{io1, io2}](f2) + f[CapSet^{io1, io2}](f3) \ No newline at end of file diff --git a/tests/neg-custom-args/captures/i21868.scala b/tests/neg-custom-args/captures/i21868.scala new file mode 100644 index 000000000000..349750a2ee4b --- /dev/null +++ b/tests/neg-custom-args/captures/i21868.scala @@ -0,0 +1,14 @@ +import caps. + +trait AbstractWrong: + type C <: CapSet + def boom(): Unit^{C^} // error + +trait Abstract: + type C <: CapSet^ + def boom(): Unit^{C^} + +class Concrete extends Abstract: + type C = Nothing + def boom() = () // error +