Skip to content

Commit

Permalink
Fix setup of CapSet arguments.
Browse files Browse the repository at this point in the history
These arguments tell the whole truth; they cannot possibly be decorated with another capture set. So
we should not add a capture set variable.
  • Loading branch information
odersky committed Jul 31, 2024
1 parent 3dfd762 commit c47affc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/cc/Setup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,10 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
!refs.isEmpty
case tp: (TypeRef | AppliedType) =>
val sym = tp.typeSymbol
if sym.isClass then !sym.isPureClass
else instanceCanBeImpure(tp.superType)
if sym.isClass
then !sym.isPureClass
else !tp.derivesFrom(defn.Caps_CapSet) // CapSet arguments don't get other capture set variables added
&& instanceCanBeImpure(tp.superType)
case tp: (RefinedOrRecType | MatchType) =>
instanceCanBeImpure(tp.underlying)
case tp: AndType =>
Expand Down
14 changes: 14 additions & 0 deletions tests/pos/polycap.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import language.experimental.captureChecking

class Source[+T, Cap^]

def completed[T, Cap^](result: T): Source[T, Cap] =
//val fut = new Source[T, Cap]()
val fut2 = new Source[T, Cap]()
fut2: Source[T, Cap]






0 comments on commit c47affc

Please sign in to comment.