Skip to content

Commit c47affc

Browse files
committed
Fix setup of CapSet arguments.
These arguments tell the whole truth; they cannot possibly be decorated with another capture set. So we should not add a capture set variable.
1 parent 3dfd762 commit c47affc

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,10 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
605605
!refs.isEmpty
606606
case tp: (TypeRef | AppliedType) =>
607607
val sym = tp.typeSymbol
608-
if sym.isClass then !sym.isPureClass
609-
else instanceCanBeImpure(tp.superType)
608+
if sym.isClass
609+
then !sym.isPureClass
610+
else !tp.derivesFrom(defn.Caps_CapSet) // CapSet arguments don't get other capture set variables added
611+
&& instanceCanBeImpure(tp.superType)
610612
case tp: (RefinedOrRecType | MatchType) =>
611613
instanceCanBeImpure(tp.underlying)
612614
case tp: AndType =>

tests/pos/polycap.scala

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import language.experimental.captureChecking
2+
3+
class Source[+T, Cap^]
4+
5+
def completed[T, Cap^](result: T): Source[T, Cap] =
6+
//val fut = new Source[T, Cap]()
7+
val fut2 = new Source[T, Cap]()
8+
fut2: Source[T, Cap]
9+
10+
11+
12+
13+
14+

0 commit comments

Comments
 (0)