Skip to content

Commit 2b51ee9

Browse files
committed
Document and polish CheckCaptures
1 parent eb0577f commit 2b51ee9

File tree

4 files changed

+326
-216
lines changed

4 files changed

+326
-216
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ end CCState
127127
def ccState(using Context) =
128128
Phases.checkCapturesPhase.asInstanceOf[CheckCaptures].ccState1
129129

130-
class NoCommonRoot(rs: Symbol*)(using Context) extends Exception(
131-
i"No common capture root nested in ${rs.mkString(" and ")}"
132-
)
133-
134130
extension (tree: Tree)
135131

136132
/** Map tree with CaptureRef type to its type,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,12 @@ sealed abstract class CaptureSet extends Showable:
185185

186186
/** A more optimistic version of subCaptures used to choose one of two typing rules
187187
* for selections and applications. `cs1 mightSubcapture cs2` if `cs2` might account for
188-
* every element currently known to be in `cs1`.
188+
* every element currently known to be in `cs1`, and the same is not true in reverse
189+
* when we compare elements of cs2 vs cs1.
189190
*/
190191
def mightSubcapture(that: CaptureSet)(using Context): Boolean =
191192
elems.forall(that.mightAccountFor)
193+
&& !that.elems.forall(this.mightAccountFor)
192194

193195
/** The subcapturing test.
194196
* @param frozen if true, no new variables or dependent sets are allowed to

0 commit comments

Comments
 (0)