File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,15 @@ case class CaptureSet private (elems: CaptureSet.Refs) extends Showable:
54
54
def <:< (that : CaptureSet )(using Context ): Boolean =
55
55
elems.isEmpty || elems.forall(that.accountsFor)
56
56
57
+ def flatMap (f : CaptureRef => CaptureSet )(using Context ): CaptureSet =
58
+ (empty /: elems)((cs, ref) => cs ++ f(ref))
59
+
60
+ def substParams (tl : BindingType , to : List [Type ])(using Context ) =
61
+ flatMap {
62
+ case ref : ParamRef if ref.binder eq tl => to(ref.paramNum).captureSet
63
+ case ref => ref.singletonCaptureSet
64
+ }
65
+
57
66
override def toString = elems.toString
58
67
59
68
override def toText (printer : Printer ): Text =
@@ -98,6 +107,11 @@ object CaptureSet:
98
107
tp.captureSet
99
108
case CapturingType (parent, ref) =>
100
109
recur(parent) + ref
110
+ case AppliedType (tycon, args) =>
111
+ val cs = recur(tycon)
112
+ tycon.typeParams match
113
+ case tparams @ (LambdaParam (tl, _) :: _) => cs.substParams(tl, args)
114
+ case _ => cs
101
115
case tp : TypeProxy =>
102
116
recur(tp.underlying)
103
117
case AndType (tp1, tp2) =>
You can’t perform that action at this time.
0 commit comments