Skip to content

Commit

Permalink
Test for #21614 (#21615)
Browse files Browse the repository at this point in the history
  • Loading branch information
bracevac authored Sep 19, 2024
2 parents 493dbe2 + b9f86dc commit ba9e59a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/neg-custom-args/captures/i21614.check
Original file line number Diff line number Diff line change
@@ -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`
12 changes: 12 additions & 0 deletions tests/neg-custom-args/captures/i21614.scala
Original file line number Diff line number Diff line change
@@ -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?

0 comments on commit ba9e59a

Please sign in to comment.