Skip to content

CC: Type variables can be used to bypass unboxing #23746

@Linyxus

Description

@Linyxus

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions