Skip to content

Type variables with capturing bounds confuse separation checking #24539

@odersky

Description

@odersky

Compiler version

3.8.0-RC1

Minimized example

import scala.language.experimental.captureChecking
import scala.language.experimental.separationChecking

class Ref
case class Box[T](elem: T)

def h[T <: Ref^](x: Box[T]): Ref^ = x.elem

def Test =
  val r: Ref^ = Ref()
  val r2 = h(Box(r))
  println(r)

Output

compiles

Expectation

Should give an error since r2 is now an alias of r. Either function h should be rejected, or the code in Test should be illegal.

The outcome is the same if parameter x in h is declared consume.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions