Skip to content

Commit e8fb67b

Browse files
committed
Skip capture sets in checkNoPrivateLeaks when cc is not enabled
1 parent 8c9c051 commit e8fb67b

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,9 @@ object Checking {
771771
!(symBoundary.isContainedIn(otherBoundary) ||
772772
otherLinkedBoundary.exists && symBoundary.isContainedIn(otherLinkedBoundary))
773773
}
774-
&& !(inCaptureSet && other.isAllOf(LocalParamAccessor))
775-
// class parameters in capture sets are not treated as leaked since in
774+
&& !(inCaptureSet && (!Feature.ccEnabled || other.isAllOf(LocalParamAccessor)))
775+
// All references are skipped in capture sets when CC is not enabled.
776+
// Class parameters in capture sets are not treated as leaked since in
776777
// phase CheckCaptures these are treated as normal vals.
777778

778779
def apply(tp: Type): Type = tp match {

tests/pos/i23885/S_1.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import language.experimental.captureChecking
2+
3+
class A:
4+
def f(x: A^): A^{this, x} = ???

tests/pos/i23885/S_2.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class B:
2+
private val a: A = ???
3+
def g(b: A) = a.f(b)

0 commit comments

Comments
 (0)