Compiler version
main
Minimized code
import language.experimental.captureChecking
trait Op:
def run(): Unit
def helper[X <: Op^](op: X): () -> Unit = () => op.run() // should be error, but ok
def runOpForFree(op: Op^): () -> Unit = () => helper(op)
Output
It compiles.
Expectation
But it shouldn't. It converts arbitrary impure operation into a pure one, which is clearly unsound.
After some initial investigation, this seems to be an interaction between type variables, boxes, and asSeenFrom.
This is derived from the issue @noti0na1 showed during the group meeting.