Skip to content

Commit cc2b60a

Browse files
committed
Address review comments
1 parent e0c3a02 commit cc2b60a

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,10 @@ object Capabilities:
603603
def assumedContainsOf(x: TypeRef)(using Context): SimpleIdentitySet[Capability] =
604604
CaptureSet.assumedContains.getOrElse(x, SimpleIdentitySet.empty)
605605

606+
/** The type representing this capability.
607+
* Note this method does not distinguish different `RootCapability` instances,
608+
* and should only be used for printing or phases not related to CC.
609+
*/
606610
def toType(using Context): Type = this match
607611
case c: RootCapability => defn.captureRoot.termRef
608612
case c: CoreCapability => c

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
203203
)
204204
isUniversal
205205
|| !refs.elems.isEmpty && refs.elems.forall(_.isCapOrFresh) && !ccVerbose
206-
case (ref: TermRef) :: Nil => ref.symbol == defn.captureRoot
206+
case ref :: Nil => ref.isCapRef
207207
case _ => false
208208

209209
protected def toTextGeneralCaptureSet(refs: GeneralCaptureSet): Text = refs match
@@ -312,7 +312,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
312312
def arrowText: Text = restp match
313313
case AnnotatedType(parent, ann) if ann.symbol == defn.RetainsByNameAnnot =>
314314
ann.tree.retainedSet.retainedElementsRaw match
315-
case (ref: TermRef) :: Nil if ref.symbol == defn.captureRoot => Str("=>")
315+
case ref :: Nil if ref.isCapRef => Str("=>")
316316
case refs => Str("->") ~ toTextRetainedElems(refs)
317317
case _ =>
318318
if Feature.pureFunsEnabled then "->" else "=>"

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ object RefChecks {
435435

436436
def emitOverrideError(fullmsg: Message) =
437437
if !(hasErrors && member.is(Synthetic) && member.is(Module) || member.isDummyCaptureParam) then
438-
// suppress errors relating to synthetic companion objects if other override
438+
// suppress errors relating to synthetic companion objects and capture parameters if other override
439439
// errors (e.g. relating to the companion class) have already been reported.
440440
if (member.owner == clazz) report.error(fullmsg, member.srcPos)
441441
else mixinOverrideErrors += new MixinOverrideError(member, fullmsg)

0 commit comments

Comments
 (0)