From b9f86dc66e5b475ba159069eef1057210819a743 Mon Sep 17 00:00:00 2001 From: odersky Date: Thu, 19 Sep 2024 18:10:54 +0200 Subject: [PATCH] Test for #21614 --- tests/neg-custom-args/captures/i21614.check | 17 +++++++++++++++++ tests/neg-custom-args/captures/i21614.scala | 12 ++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/neg-custom-args/captures/i21614.check create mode 100644 tests/neg-custom-args/captures/i21614.scala diff --git a/tests/neg-custom-args/captures/i21614.check b/tests/neg-custom-args/captures/i21614.check new file mode 100644 index 000000000000..14b468db4c8e --- /dev/null +++ b/tests/neg-custom-args/captures/i21614.check @@ -0,0 +1,17 @@ +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21614.scala:9:33 ---------------------------------------- +9 | files.map((f: F) => new Logger(f)) // error, Q: can we make this pass (see #19076)? + | ^ + | Found: (f : F^) + | Required: File^ + | + | longer explanation available when compiling with `-explain` +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21614.scala:12:12 --------------------------------------- +12 | files.map(new Logger(_)) // error, Q: can we improve the error message? + | ^^^^^^^^^^^^^ + | Found: Logger{val f: (_$1 : File^{files*})}^ + | Required: Logger{val f: File^?}^? + | + | Note that the universal capability `cap` + | cannot be included in capture set ? + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg-custom-args/captures/i21614.scala b/tests/neg-custom-args/captures/i21614.scala new file mode 100644 index 000000000000..a5ed25d818a5 --- /dev/null +++ b/tests/neg-custom-args/captures/i21614.scala @@ -0,0 +1,12 @@ +import language.experimental.captureChecking +import caps.Capability +import caps.unbox + +trait File extends Capability +class Logger(f: File^) extends Capability // <- will work if we remove the extends clause + +def mkLoggers1[F <: File^](@unbox files: List[F]): List[Logger^] = + files.map((f: F) => new Logger(f)) // error, Q: can we make this pass (see #19076)? + +def mkLoggers2(@unbox files: List[File^]): List[Logger^] = + files.map(new Logger(_)) // error, Q: can we improve the error message?