Skip to content

Commit 38bb5eb

Browse files
committed
Mark reachCapability and readOnlyCapability as @retainsArg
Similar to scala#20232, but should apply to even reach and read-only capabilities
1 parent 797bbb7 commit 38bb5eb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

library/src/scala/caps/package.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ sealed trait Exists extends Capability
8787

8888
@experimental
8989
object internal:
90+
import annotation.retainsArg
9091

9192
/** A wrapper indicating a type variable in a capture argument list of a
9293
* @retains annotation. E.g. `^{x, Y^}` is represented as `@retains(x, capsOf[Y])`.
@@ -98,13 +99,13 @@ object internal:
9899
* as `caps.reachCapability(x)`. When converted to CaptureRef types in capture sets
99100
* they are represented as `x.type @annotation.internal.reachCapability`.
100101
*/
101-
extension (x: Any) def reachCapability: Any = x
102+
extension (x: Any @retainsArg) def reachCapability: Any = x
102103

103104
/** Read-only capabilities x.rd which appear as terms in @retains annotations are encoded
104105
* as `caps.readOnlyCapability(x)`. When converted to CaptureRef types in capture sets
105106
* they are represented as `x.type @annotation.internal.readOnlyCapability`.
106107
*/
107-
extension (x: Any) def readOnlyCapability: Any = x
108+
extension (x: Any @retainsArg) def readOnlyCapability: Any = x
108109

109110
/** An internal annotation placed on a refinement created by capture checking.
110111
* Refinements with this annotation unconditionally override any

0 commit comments

Comments
 (0)