Skip to content

Commit 8be05c4

Browse files
committed
Fix rebase breakage
1 parent 174849d commit 8be05c4

File tree

5 files changed

+10
-80
lines changed

5 files changed

+10
-80
lines changed

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

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -703,14 +703,6 @@ object Capabilities:
703703
(this eq y)
704704
|| this.match
705705
case x: FreshCap =>
706-
def levelOK =
707-
if ccConfig.useFreshLevels && !CCState.collapseFresh then
708-
val yOwner = y.levelOwner
709-
yOwner.isStaticOwner || x.ccOwner.isContainedIn(yOwner)
710-
else y.core match
711-
case ResultCap(_) | _: ParamRef => false
712-
case _ => true
713-
714706
vs.ifNotSeen(this)(x.hiddenSet.elems.exists(_.subsumes(y)))
715707
|| x.acceptsLevelOf(y)
716708
&& ( y.tryClassifyAs(x.hiddenSet.classifier)
@@ -1017,69 +1009,6 @@ object Capabilities:
10171009
def inverse = Inverse()
10181010
end Internalize
10191011

1020-
/** The local dual of a result type of a closure type.
1021-
* @param binder the method type of the anonymous function whose result is mapped
1022-
* @pre the context's owner is the anonymous function
1023-
*/
1024-
class Internalize(binder: MethodType)(using Context) extends BiTypeMap:
1025-
thisMap =>
1026-
1027-
val sym = ctx.owner
1028-
assert(sym.isAnonymousFunction)
1029-
val paramSyms = atPhase(ctx.phase.prev):
1030-
// We need to ask one phase before since `sym` should not be completed as a side effect.
1031-
// The result of Internalize is used to se the result type of an anonymous function, and
1032-
// the new info of that function is built with the result.
1033-
sym.paramSymss.head
1034-
val resultToFresh = EqHashMap[ResultCap, FreshCap]()
1035-
val freshToResult = EqHashMap[FreshCap, ResultCap]()
1036-
1037-
override def apply(t: Type) =
1038-
if variance < 0 then t
1039-
else t match
1040-
case t: ParamRef =>
1041-
if t.binder == this.binder then paramSyms(t.paramNum).termRef else t
1042-
case _ => mapOver(t)
1043-
1044-
override def mapCapability(c: Capability, deep: Boolean): Capability = c match
1045-
case r: ResultCap if r.binder == this.binder =>
1046-
resultToFresh.get(r) match
1047-
case Some(f) => f
1048-
case None =>
1049-
val f = FreshCap(Origin.LocalInstance(binder.resType))
1050-
resultToFresh(r) = f
1051-
freshToResult(f) = r
1052-
f
1053-
case _ =>
1054-
super.mapCapability(c, deep)
1055-
1056-
class Inverse extends BiTypeMap:
1057-
def apply(t: Type): Type =
1058-
if variance < 0 then t
1059-
else t match
1060-
case t: TermRef if paramSyms.contains(t) =>
1061-
binder.paramRefs(paramSyms.indexOf(t.symbol))
1062-
case _ => mapOver(t)
1063-
1064-
override def mapCapability(c: Capability, deep: Boolean): Capability = c match
1065-
case f: FreshCap if f.owner == sym =>
1066-
freshToResult.get(f) match
1067-
case Some(r) => r
1068-
case None =>
1069-
val r = ResultCap(binder)
1070-
resultToFresh(r) = f
1071-
freshToResult(f) = r
1072-
r
1073-
case _ => super.mapCapability(c, deep)
1074-
1075-
def inverse = thisMap
1076-
override def toString = thisMap.toString + ".inverse"
1077-
end Inverse
1078-
1079-
override def toString = "InternalizeClosureResult"
1080-
def inverse = Inverse()
1081-
end Internalize
1082-
10831012
/** Map top-level free existential variables one-to-one to Fresh instances */
10841013
def resultToFresh(tp: Type, origin: Origin)(using Context): Type =
10851014
val subst = new TypeMap:

tests/neg-custom-args/captures/i21347.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
| ^^^^^^^^^^^^^^^^^^^^^^
44
| Found: () ->{f} Unit
55
| Required: () -> Unit
6-
| Note that capability (f : () => Unit) is not included in capture set {}.
6+
| Note that capability f is not included in capture set {}.
77
|
88
| longer explanation available when compiling with `-explain`
99
-- Error: tests/neg-custom-args/captures/i21347.scala:11:15 ------------------------------------------------------------

tests/neg-custom-args/captures/i21614.check

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21614.scala:15:12 ---------------------------------------
1313
15 | files.map(new Logger(_)) // error, Q: can we improve the error message?
1414
| ^^^^^^^^^^^^^
15-
|Found: (_$1: File^?) ->{C} Logger{val f: File^{_$1}}^{cap.rd, _$1}
16-
|Required: File^{C} => Logger{val f: File^?}^?
15+
|Found: (_$1: File^'s1) ->{C} Logger{val f: File^{_$1}}^{cap.rd, _$1}
16+
|Required: File^{C} => Logger{val f: File^'s2}^'s3
1717
|
1818
|where: => refers to a fresh root capability created in method mkLoggers2 when checking argument to parameter f of method map
1919
| cap is a root capability associated with the result type of (_$1: File^'s1): Logger{val f: File^{_$1}}^{cap.rd, _$1}
2020
|
21-
|Note that capability <cap of (_$1: File^{files*}): Logger{val f: File^'s2}^'s3>.rd cannot be included in outer capture set 's3.
21+
|Note that capability C is not classified as trait SharedCapability, therefore it
22+
|cannot be included in capture set 's1 of parameter _$1 of SharedCapability elements.
2223
|
2324
| longer explanation available when compiling with `-explain`

tests/neg-custom-args/captures/reaches.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@
108108
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:90:10 --------------------------------------
109109
90 | ps.map((x, y) => compose1(x, y)) // error
110110
| ^^^^^^^^^^^^^^^^^^^^^^^
111-
|Found: (x$1: (A^ ->? A^?, A^ ->? A^?)^?) ->? A^? ->? A^?
112-
|Required: ((A ->{C} A, A ->{C} A)) => A^? ->? A^?
111+
|Found: (x$1: (A^ ->'s20 A^'s21, A^ ->'s22 A^'s23)^'s24) ->'s25 A^'s26 ->'s27 A^'s28
112+
|Required: ((A ->{C} A, A ->{C} A)) => A^'s29 ->'s30 A^'s31
113113
|
114114
|where: => refers to a fresh root capability created in method mapCompose2 when checking argument to parameter f of method map
115115
| ^ refers to the universal root capability

tests/neg-custom-args/captures/vars.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/vars.scala:36:8 ------------------------------------------
2828
36 | local { cap3 => // error
2929
| ^
30-
| Found: (cap3: CC^) ->'s1 String => String
31-
| Required: CC^ -> String =>² String
30+
|Found: (cap3: CC^) ->'s1 String => String
31+
|Required: CC^ -> String =>² String
3232
|
3333
|where: => refers to a root capability associated with the result type of (cap3: CC^): String => String
3434
| =>² refers to a fresh root capability created in method test of parameter parameter cap3² of method $anonfun
3535
| ^ refers to the universal root capability
3636
|
37-
| Note that capability <cap of (cap3: CC^): String => String> cannot be included in outer capture set {cap}.
37+
|Note that capability <cap of (cap3: CC^): String => String> cannot be included in outer capture set {cap}.
3838
37 | def g(x: String): String = if cap3 == cap3 then "" else "a"
3939
38 | g
4040
39 | }

0 commit comments

Comments
 (0)