Skip to content

Commit b344155

Browse files
committed
Fix test
1 parent 4314cdd commit b344155

File tree

9 files changed

+25
-51
lines changed

9 files changed

+25
-51
lines changed

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
536536
else
537537
val trefs =
538538
if refs.isEmpty then ref(defn.NothingType)
539-
// TODO: choose a reduce direction
540539
else refs.map(SingletonTypeTree).reduce[Tree]((a, b) => makeOrType(a, b))
541540
annot = New(AppliedTypeTree(annot, trefs :: Nil), Nil)
542541
annot.putAttachment(RetainsAnnot, ())

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

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -932,15 +932,10 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
932932
*/
933933
private def checkWellformed(parent: Type, ann: Tree, tpt: Tree)(using Context): Unit =
934934
capt.println(i"checkWF post $parent ${ann.retainedSet} in $tpt")
935-
var retained = ann.retainedSet.retainedElems.toArray
936-
for i <- 0 until retained.length do
937-
val refTree = retained(i)
938-
val refs =
939-
try refTree.toCaptureRefs
940-
catch case ex: IllegalCaptureRef =>
941-
report.error(em"Illegal capture reference: ${ex.getMessage}", refTree.srcPos)
942-
Nil
943-
for ref <- refs do
935+
try
936+
var retained = ann.retainedSet.retainedElements.toArray
937+
for i <- 0 until retained.length do
938+
val ref = retained(i)
944939
def pos =
945940
if ann.span.exists then ann.srcPos
946941
else tpt.srcPos
@@ -958,15 +953,15 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
958953

959954
val others =
960955
for
961-
j <- 0 until retainedRefs.length if j != i
962-
r = retainedRefs(j)
956+
j <- 0 until retained.length if j != i
957+
r = retained(j)
963958
if !r.isRootCapability
964959
yield r
965960
val remaining = CaptureSet(others*)
966961
check(remaining, remaining)
967962
end for
968963
catch case ex: IllegalCaptureRef =>
969-
report.error(em"Illegal capture reference: ${ex.getMessage.nn}", tpt.srcPos)
964+
report.error(em"Illegal capture reference: ${ex.getMessage}", tpt.srcPos)
970965
end checkWellformed
971966

972967
/** Check well formed at post check time. We need to wait until after

compiler/src/dotty/tools/dotc/transform/Getters.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Getters extends MiniPhase with SymTransformer { thisPhase =>
8989
else d1 = d1.copySymDenotation(initFlags = d1.flags &~ Local)
9090
d1
9191
}
92-
private val NoGetterNeededFlags = Method | Param | JavaDefined | JavaStatic
92+
private val NoGetterNeededFlags = Method | Param | JavaDefined | JavaStatic | CaptureParam
9393

9494
val newSetters = util.HashSet[Symbol]()
9595

tests/neg-custom-args/captures/i21868.scala

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/pos-custom-args/captures/byname.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ def test(cap1: Cap, cap2: Cap): I^{cap1} =
99
def f() = if cap1 == cap1 then I() else I()
1010
def h(x: ->{cap} I) = x
1111
h(f()) // OK
12-
def hh(x: -> I @retainsByName(cap1)) = x
12+
def hh(x: -> I @retainsByName[cap1.type]) = x
1313
h(f())
1414

tests/pos-custom-args/captures/capt0.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ object Test:
22

33
def test() =
44
val x: Any^ = "abc"
5-
val y: Object @scala.annotation.retains(x) = ???
6-
val z: Object @scala.annotation.retains(x, caps.cap) = y: Object @annotation.retains(x)
5+
val y: Object @scala.annotation.retains[x.type] = ???
6+
val z: Object @scala.annotation.retains[x.type | caps.cap.type] = y: Object @annotation.retains[x.type]
77

tests/pos-custom-args/captures/colltest.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import language.experimental.captureChecking
12
// Showing a problem with recursive references
23
object CollectionStrawMan5 {
34

@@ -17,14 +18,13 @@ object CollectionStrawMan5 {
1718
trait View[+A] extends Iterable[A] with IterableLike[A]
1819

1920
case class Partition[A](val underlying: Iterable[A]^, p: A => Boolean) {
20-
self: Partition[A]^{underlying, p} =>
2121

2222
class Partitioned(expected: Boolean) extends View[A]:
23-
this: Partitioned^{self} =>
23+
this: Partitioned^{Partition.this} =>
2424
def iterator: Iterator[A]^{this} =
2525
underlying.iterator.filter((x: A) => p(x) == expected)
2626

27-
val left: Partitioned^{self} = Partitioned(true)
28-
val right: Partitioned^{self} = Partitioned(false)
27+
val left: Partitioned^{Partition.this} = Partitioned(true)
28+
val right: Partitioned^{Partition.this} = Partitioned(false)
2929
}
3030
}

tests/pos-custom-args/captures/i21868.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import language.experimental.captureChecking
22
import caps.*
33

44
trait AbstractWrong:
5-
type C <: CapSet
5+
type C <: CapSet // no longer an error, the lower bound becomes CapSet now
66
def f(): Unit^{C}
77

88
trait Abstract1:
9-
type C^
9+
type C >: CapSet <: CapSet^
1010
def f(): Unit^{C}
1111

12-
// class Abstract2:
13-
// type C^
14-
// def f(): Unit^{C^}
12+
trait Abstract2:
13+
type C <: {cap}
14+
def f(): Unit^{C}

tests/run-custom-args/captures/colltest5/CollectionStrawManCC5_1.scala

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import annotation.tailrec
88
import caps.cap
99
import caps.unsafe.unsafeAssumeSeparate
1010

11+
import language.experimental.captureChecking
12+
1113
/** A strawman architecture for new collections. It contains some
1214
* example collection classes and methods with the intent to expose
1315
* some key issues. It would be good to compare this to other
@@ -448,7 +450,6 @@ object CollectionStrawMan5 {
448450
}
449451

450452
case class Filter[A](val underlying: Iterable[A]^, p: A => Boolean) extends View[A] {
451-
this: Filter[A]^{underlying, p} =>
452453
def iterator: Iterator[A]^{this} = underlying.iterator.filter(p)
453454
}
454455

@@ -466,37 +467,31 @@ object CollectionStrawMan5 {
466467
case _ => new Filter(underlying, pp)
467468

468469
case class Partition[A](val underlying: Iterable[A]^, p: A => Boolean) {
469-
self: Partition[A]^{underlying, p} =>
470-
471470
class Partitioned(expected: Boolean) extends View[A]:
472-
this: Partitioned^{self} =>
471+
this: Partitioned^{Partition.this} =>
473472
def iterator: Iterator[A]^{this} =
474473
underlying.iterator.filter((x: A) => p(x) == expected)
475474

476-
val left: Partitioned^{self} = Partitioned(true)
477-
val right: Partitioned^{self} = Partitioned(false)
475+
val left: Partitioned^{this} = Partitioned(true)
476+
val right: Partitioned^{this} = Partitioned(false)
478477
}
479478

480479
case class Drop[A](underlying: Iterable[A]^, n: Int) extends View[A] {
481-
this: Drop[A]^{underlying} =>
482480
def iterator: Iterator[A]^{this} = underlying.iterator.drop(n)
483481
override def knownLength =
484482
if (underlying.knownLength >= 0) underlying.knownLength - n max 0 else -1
485483
}
486484

487485
case class Map[A, B](underlying: Iterable[A]^, f: A => B) extends View[B] {
488-
this: Map[A, B]^{underlying, f} =>
489486
def iterator: Iterator[B]^{this} = underlying.iterator.map(f)
490487
override def knownLength = underlying.knownLength
491488
}
492489

493490
case class FlatMap[A, B](underlying: Iterable[A]^, f: A => IterableOnce[B]^) extends View[B] {
494-
this: FlatMap[A, B]^{underlying, f} =>
495491
def iterator: Iterator[B]^{this} = underlying.iterator.flatMap(f)
496492
}
497493

498494
case class Concat[A](underlying: Iterable[A]^, other: IterableOnce[A]^) extends View[A] {
499-
this: Concat[A]^{underlying, other} =>
500495
def iterator: Iterator[A]^{this} = underlying.iterator ++ other
501496
override def knownLength = other match {
502497
case other: Iterable[_] if underlying.knownLength >= 0 && other.knownLength >= 0 =>
@@ -507,7 +502,6 @@ object CollectionStrawMan5 {
507502
}
508503

509504
case class Zip[A, B](underlying: Iterable[A]^, other: IterableOnce[B]^) extends View[(A, B)] {
510-
this: Zip[A, B]^{underlying, other} =>
511505
def iterator: Iterator[(A, B)]^{this} = underlying.iterator.zip(other)
512506
override def knownLength = other match {
513507
case other: Iterable[_] if underlying.knownLength >= 0 && other.knownLength >= 0 =>

0 commit comments

Comments
 (0)