Skip to content

Commit ba1ef96

Browse files
committed
Avoid assertion violation due to empty footprint overlap
- Drop the assertion and handle the case of empty overlap - At the same time, avoid the empty overlap by taking complete instead of direct footprints. Also: Improve printing of FreshCap prefixes
1 parent 93cb35c commit ba1ef96

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ object SepCheck:
272272
* 3. the set itself if it consists only of hidden terminal capabilities.
273273
*/
274274
def reduced(using Context): Refs =
275-
assert(!refs.isEmpty)
276275
val concrete = refs.nonPeaks
277276
if !concrete.isEmpty then concrete
278277
else
@@ -356,9 +355,10 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
356355
val hiddenFootprint = hiddenSet.directFootprint
357356
val clashFootprint = clashSet.directFootprint
358357
val shared = hiddenFootprint.overlapWith(clashFootprint).reduced
359-
shared.nth(0) match
358+
if shared.isEmpty then i"${CaptureSet(shared)}"
359+
else shared.nth(0) match
360360
case fresh: FreshCap =>
361-
if fresh.hiddenSet.owner.exists then i"$fresh of ${fresh.hiddenSet.owner}" else i"$fresh"
361+
if fresh.hiddenSet.owner.exists then i"{$fresh of ${fresh.hiddenSet.owner}}" else i"$fresh"
362362
case _ =>
363363
i"${CaptureSet(shared)}"
364364

@@ -402,8 +402,9 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
402402
else i" with type ${clashing.nuType}"
403403
val hiddenSet = formalCaptures(polyArg).transHiddenSet
404404
val clashSet = if clashIdx == -1 then deepCaptures(clashing) else spanCaptures(clashing)
405-
val hiddenFootprint = hiddenSet.directFootprint
406-
val clashFootprint = clashSet.directFootprint
405+
val hiddenFootprint = hiddenSet.completeFootprint
406+
val clashFootprint = clashSet.completeFootprint
407+
407408
report.error(
408409
em"""Separation failure: argument of type ${polyArg.nuType}
409410
|to $funStr

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ class PlainPrinter(_ctx: Context) extends Printer {
493493
else s" classified as ${c.hiddenSet.classifier.name.show}"
494494
def prefixTxt: Text = c.prefix match
495495
case NoPrefix | _: ThisType => ""
496-
case pre => pre.show ~ "."
496+
case pre: SingletonType => toTextRef(pre) ~ "."
497+
case pre => toText(pre) ~ "."
497498
def core: Text =
498499
if ccVerbose then s"<fresh$idStr in ${c.ccOwner} hiding " ~ toTextCaptureSet(c.hiddenSet) ~ classified ~ ">"
499500
else "cap"

0 commit comments

Comments
 (0)