-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
Compiler version
main
Minimized code
import language.experimental.captureChecking
import caps.*
def test1() =
val z: Any^ = ???
def onlyWithZ[C^](using c: Contains[C, z.type]) = ???
onlyWithZ[{z}] // error, but should be ok
def test2(z: Any^) =
def onlyWithZ[C^](using c: Contains[C, z.type]) = ???
onlyWithZ[{z}] // ok
Output
[info] running (fork) dotty.tools.dotc.Main -d /Users/linyxus/Workspace/dotty/compiler/../out/default-last-scalac-out.jar -classpath /Users/linyxus/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.16/scala-library-2.13.16.jar:/Users/linyxus/Workspace/dotty/library/../out/bootstrap/scala3-library-bootstrapped/scala-3.8.0-RC1-bin-SNAPSHOT-nonbootstrapped/scala3-library_3-3.8.0-RC1-bin-SNAPSHOT.jar -color:never issues/cclevel-contains.scala
-- [E007] Type Mismatch Error: issues/cclevel-contains.scala:6:16 ----------------------------------------------------------------------------------------------------------------------
6 | onlyWithZ[{z}] // error, but should be ok
| ^
| Found: scala.caps.Contains.containsImpl[scala.caps.CapSet^, (z : Any^)^{z}]
| Required: scala.caps.Contains[scala.caps.CapSet^{z}, (z : Any^)^{z}]
|
| Note that capability cap is not included in capture set {z}.
|
| where: ^ refers to a fresh root capability in the type of value z
| cap is a fresh root capability in the type of value z
|
| longer explanation available when compiling with `-explain`
1 error found
[error] nonzero exit code returned from runner: 1
[error] (scala3-compiler / Compile / runMain) nonzero exit code returned from runner: 1
[error] Total time: 2 s, completed 23 Sept 2025, 13:31:39
Expectation
There should be no error. A leftover issue from PR #23934.