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.