Skip to content

Capture leak by parent boxed field #23575

@noti0na1

Description

@noti0na1

Compiler version

3.7.3-RC1-bin-SNAPSHOT-nonbootstrapped-git-42fdd76

Minimized code

import language.experimental.captureChecking
import annotation.constructorOnly
import caps.*

trait IO:
  def run(): Unit

case class Box[T](value: T)

def hideIO(io: IO^): IO =
  class LocalIOBox extends Box(io), IO:
    def run(): Unit = value.run()
  val pure: IO = new LocalIOBox
  pure

class IOBox(@constructorOnly io: IO^) extends Box(io), IO:
  def run(): Unit = value.run()

def hideIO2(io: IO^): IO =
  val pure: IO = new IOBox(io)
  pure

Output

Compile success

Expectation

The constructor of *IOBox should refine the parent field value and charge io to the capture set.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions