Skip to content

Issue with classes taking capabilities only in their method parameters #24145

@odersky

Description

@odersky

Compiler version

3.8.0

Minimized example

import language.experimental.captureChecking
import language.experimental.separationChecking
import caps.*
def par(p1: () => Unit, p2: () => Unit): Unit = ???
def test(c: () => Unit): Unit =
  trait Runner:
    def runPar(p2: () ->{c} Unit): Unit
  class SomeRunner(p1: () => Unit) extends Runner:
    def runPar(p2: () ->{c} Unit): Unit =
      par(p1, p2)
  val bad = (p1: () => Unit) =>
    val r = SomeRunner(p1)
    r
  val runner: Runner^{c} = bad(c)
  runner.runPar(c)  // boom, will run `c` and `c` in parallel

Output

Compiles

Expectation

Should give an error because we end up doing a par with c and c.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:experimental:ccCapture checking relateditype:bugitype:soundnessSoundness bug (it lets us compile code that crashes at runtime with a ClassCastException)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions