@@ -58,6 +58,7 @@ object Capabilities:
58
58
trait RootCapability extends Capability :
59
59
val rootId = nextRootId
60
60
nextRootId += 1
61
+ def descr (using Context ): String
61
62
62
63
/** The base trait of all capabilties represented as types */
63
64
trait CoreCapability extends TypeProxy , Capability :
@@ -120,6 +121,7 @@ object Capabilities:
120
121
*/
121
122
@ sharable // We override below all operations that access internal capability state
122
123
object GlobalCap extends RootCapability :
124
+ def descr (using Context ) = " the universal root capability"
123
125
override val maybe = Maybe (this )
124
126
override val readOnly = ReadOnly (this )
125
127
override def reach = unsupported(" cap.reach" )
@@ -136,13 +138,21 @@ object Capabilities:
136
138
* for diagnostics
137
139
*/
138
140
case class FreshCap private (owner : Symbol , origin : Origin )(using @ constructorOnly ctx : Context ) extends RootCapability :
139
- val hiddenSet = CaptureSet .HiddenSet (owner)
140
- hiddenSet.owningCap = this
141
+ val hiddenSet = CaptureSet .HiddenSet (owner, this : @ unchecked )
142
+ // fails initialization check without the @unchecked
141
143
142
144
override def equals (that : Any ) = that match
143
145
case that : FreshCap => this eq that
144
146
case _ => false
145
147
148
+ def descr (using Context ) =
149
+ val originStr = origin match
150
+ case Origin .InDecl (sym) if sym.exists =>
151
+ origin.explanation
152
+ case _ =>
153
+ i " created in ${hiddenSet.owner.sanitizedDescription}${origin.explanation}"
154
+ i " a fresh root capability $originStr"
155
+
146
156
object FreshCap :
147
157
def apply (origin : Origin )(using Context ): FreshCap | GlobalCap .type =
148
158
if ccConfig.useSepChecks then FreshCap (ctx.owner, origin)
@@ -225,6 +235,9 @@ object Capabilities:
225
235
rcap.myOrigin = primary
226
236
primary.variants += rcap
227
237
rcap
238
+
239
+ def descr (using Context ) =
240
+ i " a root capability associated with the result type of $binder"
228
241
end ResultCap
229
242
230
243
/** A trait for references in CaptureSets. These can be NamedTypes, ThisTypes or ParamRefs,
@@ -545,7 +558,7 @@ object Capabilities:
545
558
case y : ResultCap => vs.unify(x, y)
546
559
case _ => y.derivesFromSharedCapability
547
560
if ! result then
548
- ccState.addNote (CaptureSet .ExistentialSubsumesFailure (x, y))
561
+ TypeComparer .addErrorNote (CaptureSet .ExistentialSubsumesFailure (x, y))
549
562
result
550
563
case GlobalCap =>
551
564
y match
0 commit comments