Skip to content

Commit c2bffc7

Browse files
committed
Fix capture set variable installation in Setup
1 parent dc0b43c commit c2bffc7

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
552552
case tp: (TypeRef | AppliedType) =>
553553
val sym = tp.typeSymbol
554554
if sym.isClass then
555-
sym == defn.AnyClass
555+
sym == defn.AnyClass || !sym.isPureClass
556556
// we assume Any is a shorthand of {cap} Any, so if Any is an upper
557557
// bound, the type is taken to be impure.
558558
else
@@ -708,4 +708,4 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
708708
def postCheck()(using Context): Unit =
709709
for chk <- todoAtPostCheck do chk(ctx)
710710
todoAtPostCheck.clear()
711-
end Setup
711+
end Setup
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import language.experimental.captureChecking
2+
3+
trait Resource
4+
def id[X](x: X): x.type = x
5+
def foo[M <: Resource](r: M^): Unit = id(r)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import language.experimental.captureChecking
2+
3+
trait Builder[-A, +C]
4+
trait BuildFrom[-From, -A, +C] {
5+
def newBuilder(from: From): Builder[A, C]
6+
}
7+
8+
trait Future[+T] { this: Future[T]^ =>
9+
import Future.*
10+
def foldLeft[R](r: R): R = r
11+
def traverse[A, B, M[X] <: IterableOnce[X]](in: M[A]^, bf: BuildFrom[M[A]^, B, M[B]^]): Unit =
12+
foldLeft(successful(bf.newBuilder(in)))
13+
}
14+
object Future {
15+
def successful[T](result: T): Future[T] = ???
16+
}

0 commit comments

Comments
 (0)