Skip to content

Commit 9cb9206

Browse files
committed
Address review comments
1 parent e8b8491 commit 9cb9206

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,5 @@ object CaptureRoot:
108108
end isEnclosingRoot
109109
end CaptureRoot
110110

111-
//class LevelError(val rvar: RootVar, val newBound: Symbol, val isUpper: Boolean) extends Exception
112-
113111

114112

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,15 @@ extends tpd.TreeTraverser:
242242
mapOverFollowingAliases(t)
243243

244244
private def transformExplicitType(tp: Type, boxed: Boolean, mapRoots: Boolean)(using Context): Type =
245-
val tp1 = expandAliases(if boxed then box(tp) else tp)
245+
val tp1 = expandAliases(tp)
246246
val tp2 =
247247
if mapRoots
248248
then cc.mapRoots(defn.captureRoot.termRef, ctx.owner.localRoot.termRef)(tp1)
249249
.showing(i"map roots $tp1, ${tp1.getClass} == $result", capt)
250250
else tp1
251-
if tp2 ne tp then capt.println(i"expanded: $tp --> $tp2")
252-
tp2
251+
val tp3 = if boxed then box(tp2) else tp2
252+
if tp3 ne tp then capt.println(i"expanded: $tp --> $tp3")
253+
tp3
253254

254255
/** Transform type of type tree, and remember the transformed type as the type the tree */
255256
private def transformTT(tree: TypeTree, boxed: Boolean, exact: Boolean, mapRoots: Boolean)(using Context): Unit =
@@ -463,8 +464,8 @@ extends tpd.TreeTraverser:
463464
newInfo
464465
else new LazyType:
465466
def complete(denot: SymDenotation)(using Context) =
466-
// infos other methods are determined from their definitions which
467-
// are checked on depand
467+
// infos of other methods are determined from their definitions which
468+
// are checked on demand
468469
denot.info = newInfo
469470
recheckDef(tree, sym))
470471
else updateOwner(sym)

compiler/src/dotty/tools/dotc/util/SimpleIdentitySet.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,10 @@ object SimpleIdentitySet {
142142
val y0 = f(x0.asInstanceOf[Elem])
143143
val y1 = f(x1.asInstanceOf[Elem])
144144
val y2 = f(x2.asInstanceOf[Elem])
145-
if (y0 ne y1) && (y0 ne y2) && (y1 ne y2) then Set3(y0, y1, y2)
146-
else super.map(f)
145+
if y1 eq y0 then
146+
if y2 eq y0 then Set1(y0) else Set2(y0, y2)
147+
else if (y2 eq y0) || (y2 eq y1) then Set2(y0, y1)
148+
else Set3(y0, y1, y2)
147149
def /: [A, E >: Elem <: AnyRef](z: A)(f: (A, E) => A): A =
148150
f(f(f(z, x0.asInstanceOf[E]), x1.asInstanceOf[E]), x2.asInstanceOf[E])
149151
def toList = x0.asInstanceOf[Elem] :: x1.asInstanceOf[Elem] :: x2.asInstanceOf[Elem] :: Nil
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@annotation.capability class CanIO { def use(): Unit = () }
2+
def use[X](x: X): (op: X -> Unit) -> Unit = op => op(x)
3+
def test(io: CanIO): Unit =
4+
val f = use[CanIO](io)
5+
val g: () -> Unit = () => f(x => x.use()) // error
6+
// was UNSOUND: g uses the capability io but has an empty capture set

0 commit comments

Comments
 (0)