Skip to content

Capability class is not properly boxed in implicit type argument #16725

Closed
@Linyxus

Description

@Linyxus

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions