File tree 3 files changed +18
-11
lines changed
compiler/src/dotty/tools/dotc/cc
tests/neg-custom-args/captures
3 files changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -146,9 +146,8 @@ trait CaptureRef extends TypeProxy, ValueType:
146
146
y.info match
147
147
case TypeBounds (_, hi : CaptureRef ) => this .subsumes(hi)
148
148
case _ => y.captureSetOfInfo.elems.forall(this .subsumes)
149
- case AnnotatedType (parent, ann)
150
- if ann.symbol.isRetains && parent.derivesFrom(defn.Caps_CapSet ) =>
151
- ann.tree.toCaptureSet.elems.forall(this .subsumes)
149
+ case CapturingType (parent, refs) if parent.derivesFrom(defn.Caps_CapSet ) =>
150
+ refs.elems.forall(this .subsumes)
152
151
case _ => false
153
152
|| this .match
154
153
case ReachCapability (x1) => x1.subsumes(y.stripReach)
@@ -161,9 +160,8 @@ trait CaptureRef extends TypeProxy, ValueType:
161
160
lo.subsumes(y)
162
161
case _ =>
163
162
x.captureSetOfInfo.elems.exists(_.subsumes(y))
164
- case AnnotatedType (parent, ann)
165
- if ann.symbol.isRetains && parent.derivesFrom(defn.Caps_CapSet ) =>
166
- ann.tree.toCaptureSet.elems.exists(_.subsumes(y))
163
+ case CapturingType (parent, refs) if parent.derivesFrom(defn.Caps_CapSet ) =>
164
+ refs.elems.exists(_.subsumes(y))
167
165
case _ => false
168
166
end subsumes
169
167
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ class Concrete4(a: AnyRef^) extends Abstract[CapSet^{a}]:
22
22
def boom (): AnyRef ^ {a} = a // error
23
23
24
24
class Concrete5 (a : AnyRef ^ , b : AnyRef ^ ) extends Abstract [CapSet ^ {a}]:
25
- // TODO: Crash with the type member
26
- // type C = CapSet^{a}
25
+ type C = CapSet ^ {a}
27
26
def boom (): AnyRef ^ {b} = b // error
27
+
28
+ class Concrete6 (a : AnyRef ^ , b : AnyRef ^ ) extends Abstract [CapSet ^ {a}]:
29
+ def boom (): AnyRef ^ {b} = b // error
30
+
Original file line number Diff line number Diff line change @@ -30,9 +30,15 @@ class Concrete4(io: IO^) extends Abstract2(io):
30
30
def f (file : File ) = ()
31
31
32
32
// TODO: Should be an error
33
- // class Concrete5(io1: IO^, io2: IO^) extends Abstract2(io1):
34
- // type C = CapSet^{io2}
35
- // def f(file: File^{io2}) = ()
33
+ class Concrete5 (io1 : IO ^ , io2 : IO ^ ) extends Abstract2 (io1):
34
+ // Similar to Concrete8, this type member should have overriding error.
35
+ // Parent class is Abstract2 { val io = Concrete5.this.io1 }
36
+ // Abstract2.this.C >: CapSet <: CapSet^{Concrete5.this.io1}
37
+ // Concrete5.this.C = CapSet^{Concrete5.this.io2}
38
+ // CapSet^{Concrete5.this.io2} !<:< CapSet^{Concrete5.this.io1}
39
+ // Hence, Concrete5.this.C !<:< Abstract2.this.C
40
+ type C = CapSet ^ {io2}
41
+ def f (file : File ^ {io2}) = ()
36
42
37
43
trait Abstract3 [X ^ ]:
38
44
type C >: CapSet <: X
You can’t perform that action at this time.
0 commit comments