Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions compiler/src/dotty/tools/dotc/cc/Setup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,17 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
&& !sym.owner.is(CaptureChecked)
&& !defn.isFunctionSymbol(sym.owner)

private def fluidifySelfInfo(info: Type)(using Context): Type = info match
case cinfo: ClassInfo =>
val selfInfo1 = cinfo.selfInfo match
case NoType => NoType
case tp: Type => decorate(tp, Function.const(CaptureSet.Fluid))
case self: Symbol => decorate(self.info, Function.const(CaptureSet.Fluid))
if selfInfo1 eq cinfo.selfInfo then cinfo
else cinfo.derivedClassInfo(selfInfo = selfInfo1)
case _ =>
info

/** The symbol transformer of this phase.
* - Resets `private` flags of parameter accessors so that we can refine them
* in Setup if they have non-empty capture sets.
Expand All @@ -170,6 +181,10 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
transformExplicitType(symd.info, sym)(using symCtx)
if Synthetics.needsTransform(symd) then
Synthetics.transform(symd, mappedInfo)
else if sym.isClass && !sym.is(CaptureChecked) then
val newInfo = fluidifySelfInfo(sym.info)
if newInfo ne sym.info then symd.copySymDenotation(info = newInfo)
else symd
else if isPreCC(sym) then
symd.copySymDenotation(info = fluidify(sym.info))
else if symd.owner.isTerm
Expand Down
3 changes: 3 additions & 0 deletions tests/pos/cc-self-fluid/FunSuite_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
trait FunSuite:
self: FunSuite =>
def run(): Unit
9 changes: 9 additions & 0 deletions tests/pos/cc-self-fluid/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//> using options -language:experimental.captureChecking

class IO extends caps.SharedCapability:
def println(msg: String): Unit = ()

def test(io: IO): Unit =
class FunSuite1 extends FunSuite:
self: FunSuite1^ =>
def run(): Unit = io.println("Hello")
2 changes: 2 additions & 0 deletions tests/pos/i25634/Stest_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class A:
self: A =>
3 changes: 3 additions & 0 deletions tests/pos/i25634/Stest_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import language.experimental.captureChecking

class B extends A, caps.SharedCapability
Loading