File tree Expand file tree Collapse file tree 3 files changed +18
-11
lines changed
compiler/src/dotty/tools/dotc/cc
tests/neg-custom-args/captures Expand file tree Collapse file tree 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:
146146 y.info match
147147 case TypeBounds (_, hi : CaptureRef ) => this .subsumes(hi)
148148 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)
152151 case _ => false
153152 || this .match
154153 case ReachCapability (x1) => x1.subsumes(y.stripReach)
@@ -161,9 +160,8 @@ trait CaptureRef extends TypeProxy, ValueType:
161160 lo.subsumes(y)
162161 case _ =>
163162 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))
167165 case _ => false
168166 end subsumes
169167
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ class Concrete4(a: AnyRef^) extends Abstract[CapSet^{a}]:
2222 def boom (): AnyRef ^ {a} = a // error
2323
2424class 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}
2726 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):
3030 def f (file : File ) = ()
3131
3232// 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}) = ()
3642
3743trait Abstract3 [X ^ ]:
3844 type C >: CapSet <: X
You can’t perform that action at this time.
0 commit comments