@@ -53,7 +53,7 @@ object Message:
5353 case None => false
5454 end Disambiguation
5555
56- private type Recorded = Symbol | ParamRef | SkolemType | Capability
56+ private type Recorded = Symbol | ParamRef | SkolemType | RootCapability
5757
5858 private case class SeenKey (str : String , isType : Boolean )
5959
@@ -183,31 +183,11 @@ object Message:
183183 s " is a ${ctx.printer.kindString(sym)}${sym.showExtendedLocation}${addendum(" bounds" , info)}"
184184 case tp : SkolemType =>
185185 s " is an unknown value of type ${tp.widen.show}"
186- case ref : Capability =>
186+ case ref : RootCapability =>
187187 val relation =
188188 if List (" ^" , " =>" , " ?=>" ).exists(key.startsWith) then " refers to"
189189 else " is"
190- def ownerStr (owner : Symbol ): String =
191- if owner.isConstructor then
192- i " constructor of ${ownerStr(owner.owner)}"
193- else if owner.isAnonymousFunction then
194- i " anonymous function of type ${owner.info}"
195- else if owner.name.toString.contains('$' ) then
196- ownerStr(owner.owner)
197- else
198- owner.show
199- val descr =
200- ref match
201- case GlobalCap => " the universal root capability"
202- case ref : FreshCap =>
203- val descr = ref.origin match
204- case origin @ Origin .InDecl (sym) if sym.exists =>
205- origin.explanation
206- case origin =>
207- i " created in ${ownerStr(ref.hiddenSet.owner)}${origin.explanation}"
208- i " a fresh root capability $descr"
209- case ResultCap (binder) => i " a root capability associated with the result type of $binder"
210- s " $relation $descr"
190+ s " $relation ${ref.descr}"
211191 end explanation
212192
213193 /** Produce a where clause with explanations for recorded iterms.
@@ -274,14 +254,16 @@ object Message:
274254 override def toTextCapturing (parent : Type , refs : GeneralCaptureSet , boxText : Text ) = refs match
275255 case refs : CaptureSet
276256 if isUniversalCaptureSet(refs) && ! defn.isFunctionType(parent) && ! printDebug && seen.isActive =>
277- boxText ~ toTextLocal(parent) ~ seen.record(" ^" , isType = true , refs.elems.nth(0 ))
257+ boxText
258+ ~ toTextLocal(parent)
259+ ~ seen.record(" ^" , isType = true , refs.elems.nth(0 ).asInstanceOf [RootCapability ])
278260 case _ =>
279261 super .toTextCapturing(parent, refs, boxText)
280262
281263 override def funMiddleText (isContextual : Boolean , isPure : Boolean , refs : GeneralCaptureSet | Null ): Text =
282264 refs match
283265 case refs : CaptureSet if isUniversalCaptureSet(refs) && seen.isActive =>
284- seen.record(arrow(isContextual, isPure = false ), isType = true , refs.elems.nth(0 ))
266+ seen.record(arrow(isContextual, isPure = false ), isType = true , refs.elems.nth(0 ). asInstanceOf [ RootCapability ] )
285267 case _ =>
286268 super .funMiddleText(isContextual, isPure, refs)
287269
0 commit comments