Closed
Description
Compiler version
main
Minimized code
import language.experimental.captureChecking
@annotation.capability
class CanIO
def allowIO[T](op: (c: CanIO) => T): T = ???
def bad(c: CanIO): CanIO = c
def test: Unit = {
val ok = allowIO(bad) // error
val boom = allowIO[CanIO](bad) // should be an error, too
}
Output
-- [E007] Type Mismatch Error: issues/capclass.scala:30:19 ---------------------------------------------------------------------------------------------------------------------------------------------
30 | val ok = allowIO(bad) // error
| ^^^
| Found: ? CanIO -> {*} CanIO
| Required: (c: CanIO) => box {*} CanIO
|
| longer explanation available when compiling with `-explain`
1 error found
Expectation
Both ok
and boom
should issue an error, but now boom
won't b/c of the explicit type argument. This is because in Setup
the type arugment CanIO
in allowIO[CanIO]
will not be boxed when it is written out explicitly.