Skip to content

Commit 2e4914d

Browse files
committed
Show the owner of the conflicting set in level errors
1 parent 2f97633 commit 2e4914d

19 files changed

+33
-31
lines changed

compiler/src/dotty/tools/dotc/cc/CaptureSet.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,9 @@ object CaptureSet:
13381338
val levelStr = elem match
13391339
case ref: TermRef => i", defined in ${ref.symbol.maybeOwner}\n"
13401340
case _ => " "
1341-
i"""${elem.showAsCapability}${levelStr}cannot be included in outer capture set $cs"""
1341+
val ownerStr =
1342+
if cs.owner.exists then s" which is owned by ${cs.owner}" else ""
1343+
i"""${elem.showAsCapability}${levelStr}cannot be included in outer capture set $cs$ownerStr"""
13421344
else if !elem.tryClassifyAs(cs.classifier) then
13431345
i"""${elem.showAsCapability} is not classified as ${cs.classifier}, therefore it
13441346
|cannot be included in capture set $cs of ${cs.classifier.name} elements"""

tests/neg-custom-args/captures/boundary.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| Found: scala.util.boundary.Label[Object^'s1]
66
| Required: scala.util.boundary.Label[Object^]^²
77
|
8-
| Note that capability cap cannot be included in outer capture set 's1.
8+
| Note that capability cap cannot be included in outer capture set 's1 which is owned by val local.
99
|
1010
| where: ^ and cap refer to the universal root capability
1111
| ^² refers to a fresh root capability classified as Control in the type of value local

tests/neg-custom-args/captures/effect-swaps-explicit.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
|Found: (contextual$9: boundary.Label[Result[Future[T^'s2]^'s3, E^'s4]^'s5]^'s6) ?->{fr, async} Future[T^'s7]^{fr, contextual$9}
2323
|Required: (boundary.Label[Result[Future[T^'s8]^'s9, E^'s10]]^) ?=> Future[T^'s8]^'s9
2424
|
25-
|Note that capability contextual$9 cannot be included in outer capture set 's9.
25+
|Note that capability contextual$9 cannot be included in outer capture set 's9 which is owned by method fail4.
2626
|
2727
|where: ?=> refers to a fresh root capability created in method fail4 when checking argument to parameter body of method make
2828
| ^ refers to the universal root capability

tests/neg-custom-args/captures/effect-swaps.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
|Found: (contextual$9: boundary.Label[Result[Future[T^'s2]^'s3, E^'s4]^'s5]^'s6) ?->{fr, async} Future[T^'s7]^{fr, contextual$9}
2323
|Required: (boundary.Label[Result[Future[T^'s8]^'s9, E^'s10]]^) ?=> Future[T^'s8]^'s9
2424
|
25-
|Note that capability contextual$9 cannot be included in outer capture set 's9.
25+
|Note that capability contextual$9 cannot be included in outer capture set 's9 which is owned by method fail4.
2626
|
2727
|where: ?=> refers to a fresh root capability created in method fail4 when checking argument to parameter body of method make
2828
| ^ refers to the universal root capability

tests/neg-custom-args/captures/filevar.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
|Found: (l: scala.caps.Capability^) ?->'s1 File^'s2 ->'s3 Unit
55
|Required: (l: scala.caps.Capability^) ?-> (f: File^{l}) => Unit
66
|
7-
|Note that capability l cannot be included in outer capture set 's4 of parameter f.
7+
|Note that capability l cannot be included in outer capture set 's4 of parameter f which is owned by method $anonfun.
88
|
99
|where: => refers to a root capability associated with the result type of (using l: scala.caps.Capability^): (f: File^{l}) => Unit
1010
| ^ refers to the universal root capability

tests/neg-custom-args/captures/heal-tparam-cs.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
|Found: (c: Capp^'s1) ->'s2 () ->{c} Unit
55
|Required: (c: Capp^) => () ->'s3 Unit
66
|
7-
|Note that capability c cannot be included in outer capture set 's3.
7+
|Note that capability c cannot be included in outer capture set 's3 which is owned by val test1.
88
|
99
|where: => refers to a fresh root capability created in value test1 when checking argument to parameter op of method localCap
1010
| ^ refers to the universal root capability

tests/neg-custom-args/captures/i15923.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
|Found: (lcap: scala.caps.Capability^) ?->'s1 Cap^'s2 ->'s3 Id[Cap^'s4]^'s5
55
|Required: (lcap: scala.caps.Capability^) ?-> Cap^{lcap} => Id[Cap^'s6]^'s7
66
|
7-
|Note that capability cap cannot be included in outer capture set 's6.
7+
|Note that capability cap cannot be included in outer capture set 's6 which is owned by val leak.
88
|
99
|where: => refers to a root capability associated with the result type of (using lcap: scala.caps.Capability^): Cap^{lcap} => Id[Cap^'s6]^'s7
1010
| ^ refers to the universal root capability

tests/neg-custom-args/captures/i15923a.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
|Found: (lcap: Cap^'s1) ->'s2 () ->'s3 Id[Cap^'s4]^'s5
55
|Required: (lcap: Cap^) => () =>² Id[Cap^'s6]^'s7
66
|
7-
|Note that capability cap cannot be included in outer capture set 's6.
7+
|Note that capability cap cannot be included in outer capture set 's6 which is owned by val leak.
88
|
99
|where: => refers to a fresh root capability created in value leak when checking argument to parameter op of method withCap
1010
| =>² refers to a root capability associated with the result type of (lcap: Cap^): () =>² Id[Cap^'s6]^'s7

tests/neg-custom-args/captures/i15923b.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
|Found: (x$0: Cap^) -> Id[Cap^{x$0}]
55
|Required: (lcap: Cap^) => Id[Cap^'s1]^'s2
66
|
7-
|Note that capability lcap cannot be included in outer capture set 's1.
7+
|Note that capability lcap cannot be included in outer capture set 's1 which is owned by val leak.
88
|
99
|where: => refers to a fresh root capability created in value leak when checking argument to parameter op of method withCap
1010
| ^ refers to the universal root capability

tests/neg-custom-args/captures/i21920.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
|Found: (f: File^'s1) ->'s2 Cell[File^'s3]{val head: () ->'s4 IterableOnce[File^'s5]^'s6}^'s7
55
|Required: File^ => Cell[File^'s8]{val head: () ->'s9 IterableOnce[File^'s10]^'s11}^'s12
66
|
7-
|Note that capability cap cannot be included in outer capture set 's13.
7+
|Note that capability cap cannot be included in outer capture set 's13 which is owned by method $anonfun.
88
|
99
|where: => refers to a fresh root capability created in value cell when checking argument to parameter f of method open
1010
| ^ refers to the universal root capability

0 commit comments

Comments
 (0)