File tree Expand file tree Collapse file tree 4 files changed +20
-23
lines changed
compiler/src/dotty/tools/dotc/cc
tests/neg-custom-args/captures Expand file tree Collapse file tree 4 files changed +20
-23
lines changed Original file line number Diff line number Diff line change @@ -401,9 +401,12 @@ extension (tp: Type)
401
401
if variance <= 0 then t
402
402
else t.dealias match
403
403
case t @ CapturingType (p, cs) if cs.containsCapOrFresh =>
404
- change = true
405
404
val reachRef = if cs.isReadOnly then ref.reach.readOnly else ref.reach
406
- t.derivedCapturingType(apply(p), reachRef.singletonCaptureSet)
405
+ if reachRef.singletonCaptureSet.mightSubcapture(cs) then
406
+ change = true
407
+ t.derivedCapturingType(apply(p), reachRef.singletonCaptureSet)
408
+ else
409
+ t
407
410
case t @ AnnotatedType (parent, ann) =>
408
411
// Don't map annotations, which includes capture sets
409
412
t.derivedAnnotatedType(this (parent), ann)
Original file line number Diff line number Diff line change @@ -1550,11 +1550,9 @@ class CheckCaptures extends Recheck, SymTransformer:
1550
1550
private def improveCaptures (widened : Type , prefix : Type )(using Context ): Type = prefix match
1551
1551
case ref : Capability if ref.isTracked =>
1552
1552
widened match
1553
- case widened @ CapturingType (p, refs) if ref.singletonCaptureSet.mightSubcapture(refs) =>
1554
- val improvedCs =
1555
- if widened.isBoxed then ref.reach.singletonCaptureSet
1556
- else ref.singletonCaptureSet
1557
- widened.derivedCapturingType(p, improvedCs)
1553
+ case widened @ CapturingType (p, refs)
1554
+ if ref.singletonCaptureSet.mightSubcapture(refs) && ! widened.isBoxed =>
1555
+ widened.derivedCapturingType(p, ref.singletonCaptureSet)
1558
1556
.showing(i " improve $widened to $result" , capt)
1559
1557
case _ => widened
1560
1558
case _ => widened
Original file line number Diff line number Diff line change 1
- -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches2.scala:10:8 - -------------------------------------
1
+ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches2.scala:10:10 -------------------------------------
2
2
10 | ps.map((x, y) => compose1(x, y)) // error
3
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4
- | Found: List[A^? ->{ps*, cap, cap²} A^?]
5
- | Required: List[A ->{ps*} A]
6
- |
7
- | where: cap is a fresh root capability created in method mapCompose when computing deep capture set of A
8
- | cap² is a fresh root capability created in method mapCompose when computing deep capture set of A
9
- |
10
- | Note that capability cap is not included in capture set {ps*}.
3
+ | ^^^^^^^^^^^^^^^^^^^^^^^
4
+ | Found: (x$1: (A^? ->{ps*} A^?, A^? ->{ps*} A^?)^?) ->{ps*} A^? ->{ps*} A^?
5
+ | Required: ((A ->{ps*} A, A ->{ps*} A)) -> A^? ->? A^?
6
+ | Note that capability ps* is not included in capture set {}.
11
7
|
12
8
| longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change 1
1
-- Error: tests/neg-custom-args/captures/sep-box.scala:41:9 ------------------------------------------------------------
2
2
41 | par(h1.value, h2.value) // error
3
3
| ^^^^^^^^
4
- |Separation failure: argument of type Ref^{h1.value *}
4
+ |Separation failure: argument of type Ref^{xs *}
5
5
|to method par: (x: Ref^, y: Ref^): Unit
6
6
|corresponds to capture-polymorphic formal parameter x of type Ref^
7
- |and hides capabilities {h1.value *}.
8
- |Some of these overlap with the captures of the second argument with type Ref^{h2.value *}.
7
+ |and hides capabilities {xs *}.
8
+ |Some of these overlap with the captures of the second argument with type Ref^{xs *}.
9
9
|
10
- | Hidden set of current argument : {h1.value *}
11
- | Hidden footprint of current argument : {h1.value*, xs*}
12
- | Capture set of second argument : {h2.value *}
13
- | Footprint set of second argument : {h2.value*, xs*}
10
+ | Hidden set of current argument : {xs *}
11
+ | Hidden footprint of current argument : {xs*}
12
+ | Capture set of second argument : {xs *}
13
+ | Footprint set of second argument : {xs*}
14
14
| The two sets overlap at : {xs*}
15
15
|
16
16
|where: ^ refers to a fresh root capability classified as Mutable created in method test when checking argument to parameter x of method par
You can’t perform that action at this time.
0 commit comments