File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed
compiler/src/dotty/tools/dotc/typer
docs/_docs/reference/experimental/capture-checking
tests/pos-custom-args/captures Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -995,8 +995,12 @@ class Namer { typer: Typer =>
995995 end if
996996 }
997997
998+ /** Imply `update` for consume methods in Mutable classes */
998999 private def normalizeFlags (denot : SymDenotation )(using Context ): Unit =
999- if denot.is(Method ) && denot.hasAnnotation(defn.ConsumeAnnot ) then
1000+ if denot.is(Method )
1001+ && denot.hasAnnotation(defn.ConsumeAnnot )
1002+ && denot.owner.derivesFrom(defn.Caps_Mutable )
1003+ then
10001004 denot.setFlag(Mutable )
10011005
10021006 /** Intentionally left without `using Context` parameter. We need
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ Buffers in Scala's standard library use a single-argument method `+=` instead of
195195class Buffer [T ] extends Mutable :
196196 consume def += (x : T ): Buffer [T ]^ = this // ok
197197```
198- ` consume ` on a method implies ` update ` , so there's no need to label ` += ` separately as an update method. Then we can write
198+ ` consume ` on a method in a ` Mutable ` class implies ` update ` , so there's no need to label ` += ` separately as an update method. Then we can write
199199``` scala
200200val b = Buffer [Int ]() += 1 += 2
201201val c = b += 3
Original file line number Diff line number Diff line change 1+ trait Foo extends caps.ExclusiveCapability :
2+ consume def sink : Unit = ()
You can’t perform that action at this time.
0 commit comments