scala/scala3

Wrong capture checking result with path

Opened this issue · 1 comments

Compiler version

3.4.2
3.5 nightly

Minimized code

import language.experimental.captureChecking

class A:
  val b: A = this

def test(a: A^, c: AnyRef^) =
  val c1: A^{c} = a
  val c2: A^{c} = a.b

Output

> scala-cli compile -S 3.4 Stest.scala
Compiling project (Scala 3.4.2, JVM (21))
[error] ./Stest.scala:249:19
[error] Found:    (a : A^)
[error] Required: A^{c}
[error]   val c1: A^{c} = a
[error]                   ^
Error compiling project (Scala 3.4.2, JVM (21))
Compilation failed

Expectation

a.b should capture a, and both c1 and c2 should produce errors.

I'm not sure the c is relevant

def test(a: A^) =
  val c2: A = a.b // ok
  val c1: A = a   // err