Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
11 changes: 11 additions & 0 deletions compiler/src/dotty/tools/dotc/cc/Setup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,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 = fluidify(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 Expand Up @@ -949,6 +953,13 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
*/
private def fluidify(using Context) = new TypeMap:
def apply(t: Type): Type = t match
case cinfo: ClassInfo =>
val selfInfo1: TypeOrSymbol = cinfo.selfInfo match
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use givenSelfTyoe here to simplify the logic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. I wasn't aware of this helper! Thanks.

case selfInfo: Type =>
inContext(ctx.withOwner(cinfo.cls))(atVariance(0)(this(selfInfo)))
case self: Symbol =>
inContext(ctx.withOwner(cinfo.cls))(atVariance(0)(this(self.info)))
cinfo.derivedClassInfo(selfInfo = selfInfo1)
case t: MethodType =>
mapOver(t)
case t: TypeLambda =>
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