File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
compiler/src/dotty/tools/dotc/cc
tests/pos-custom-args/captures Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -1116,13 +1116,15 @@ object CaptureSet:
1116
1116
/** The deep capture set of a type is the union of all covariant occurrences of
1117
1117
* capture sets. Nested existential sets are approximated with `cap`.
1118
1118
* NOTE: The traversal logic needs to be in sync with narrowCaps in CaptureOps, which
1119
- * replaces caps with reach capabilties.
1119
+ * replaces caps with reach capabilties. The one exception to this is invariant
1120
+ * arguments. This have to be included to be conservative in dcs but must be
1121
+ * excluded in narrowCaps.
1120
1122
*/
1121
1123
def ofTypeDeeply (tp : Type )(using Context ): CaptureSet =
1122
1124
val collect = new TypeAccumulator [CaptureSet ]:
1123
1125
val seen = util.HashSet [Symbol ]()
1124
1126
def apply (cs : CaptureSet , t : Type ) =
1125
- if variance <= 0 then cs
1127
+ if variance < 0 then cs
1126
1128
else t.dealias match
1127
1129
case t @ CapturingType (p, cs1) =>
1128
1130
this (cs, p) ++ cs1
Original file line number Diff line number Diff line change
1
+ class Box [A ](val elem : A )
2
+ class CoBox [+ A ](val elem : A )
3
+
4
+ def applyAll [A ](fs : Box [A => Unit ], x : A ): Box [() -> {fs* } Unit ] =
5
+ Box (() => fs.elem(x))
6
+
7
+ def applyAllCo [A ](fs : CoBox [A => Unit ], x : A ): CoBox [() -> {fs* } Unit ] =
8
+ CoBox (() => fs.elem(x))
9
+
10
+ // Same with inferred result types
11
+ def test =
12
+ def applyAll [A ](fs : Box [A => Unit ], x : A ) =
13
+ Box (() => fs.elem(x))
14
+
15
+ def applyAllCo [A ](fs : CoBox [A => Unit ], x : A ) =
16
+ CoBox (() => fs.elem(x))
17
+
You can’t perform that action at this time.
0 commit comments