Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclusive capabilities #22218

Draft
wants to merge 47 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
9aaf684
Elide capabilities implied by Capability subtypes when printing
odersky Dec 6, 2024
d5cb882
Add Mutable trait and mut modifier
odersky Nov 27, 2024
4c28416
Allow other uses of Mutable flag outside vars
odersky Nov 27, 2024
26e2b03
Merge Mut and Mutable flags
odersky Nov 27, 2024
15b3838
Disallow mut methods overriding normal methods
odersky Nov 27, 2024
93f96ea
Add readOnly capabilities
odersky Nov 29, 2024
690c694
Fixes to capability ordering and handling root capabilities
odersky Dec 3, 2024
91eeccf
Disallow update methods which are not members of classes extending Mu…
odersky Dec 3, 2024
0fb91b1
Implement readOnly access
odersky Dec 3, 2024
e5222aa
Check that update methods are only called on references with exclusiv…
odersky Dec 5, 2024
5fcf077
Use cap.rd as default capture set of Capability subtypes
odersky Dec 6, 2024
5646fce
Narrow retained capture set if expected type is read-only.
odersky Dec 7, 2024
9f943fa
Make Mutable a Capability
odersky Dec 8, 2024
6b703f2
Use {cap} as capture set for creation of types extending Mutable
odersky Dec 8, 2024
65f758e
Infrastructure for fresh capture refs
odersky Dec 14, 2024
12313d8
Drop special handling of functions with pure arguments in Existential…
odersky Dec 15, 2024
1119e0f
Simplify CaptureSet.ofInfo
odersky Dec 15, 2024
d8c65c4
WIP: Move from cap to Fresh.Cap
odersky Dec 15, 2024
62723ec
Print "<cap hiding ...>" only under -Yprint-debug
odersky Dec 16, 2024
de75e07
Fix fresh handling and turn it on by default
odersky Dec 16, 2024
ecc2e24
Improve subsumes test
odersky Dec 16, 2024
aed3ed5
Revert TastyFormat changes and fix Mima filters
odersky Dec 16, 2024
a6ab8a3
Refactor handling of rechecked types
odersky Dec 18, 2024
4a67427
Fix: Use cap instead of Fresh.Cap for parameter types of methods
odersky Dec 19, 2024
6eb9e96
Fix: Skip existentials in when accessing result type in augmentConstr…
odersky Dec 19, 2024
2c01325
Turn on separation checking for applications
odersky Dec 21, 2024
007be16
Refine FrozenState categorizations
odersky Dec 21, 2024
f2f5a23
Improve error message
odersky Dec 22, 2024
de5f0f7
Simplify accountsFor
odersky Dec 23, 2024
dbcb7fb
Fix various issues with maximal capabilities
odersky Dec 29, 2024
0524397
Expand aliases when mapping explicit types in Setup
odersky Dec 31, 2024
dc8fff1
Revise handing of @uncheckedAnnotation
odersky Jan 1, 2025
0eb874f
Fix printing of capturesets containing cap and some other capability
odersky Jan 2, 2025
8a829de
Fixes to separation checks
odersky Jan 2, 2025
7946a69
Don't allow cap to subsume other references in Frozen.All
odersky Jan 2, 2025
f206410
Fix to separation checks for curried parameter lists
odersky Jan 3, 2025
5a341e7
More tests
odersky Jan 3, 2025
a8a51c2
Improve separation error diagnostics
odersky Jan 5, 2025
3cf8e37
Don't add to hidden sets in mightSubsume
odersky Jan 5, 2025
825fc2d
Revise separation checks
odersky Jan 7, 2025
58cc960
Add @sharable
odersky Jan 7, 2025
2da4277
Streamline SepChecker
odersky Jan 7, 2025
62a6513
Refactor VarState
odersky Jan 8, 2025
f82a60a
Make SimpleIdentitySets showable
odersky Jan 10, 2025
d012214
Refacture and document CaputureSet
odersky Jan 10, 2025
a210cb8
Standardize on followAliases = true
odersky Jan 10, 2025
498f43d
Require -source future for separation checking being turned on
odersky Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I, val frontendAcce
// tests/run/serialize.scala and https://github.com/typelevel/cats-effect/pull/2360).
val privateFlag = !sym.isClass && (sym.is(Private) || (sym.isPrimaryConstructor && sym.owner.isTopLevelModuleClass))

val finalFlag = sym.is(Final) && !toDenot(sym).isClassConstructor && !sym.is(Mutable, butNot = Accessor) && !sym.enclosingClass.is(Trait)
val finalFlag = sym.is(Final) && !toDenot(sym).isClassConstructor && !sym.isMutableVar && !sym.enclosingClass.is(Trait)

import asm.Opcodes.*
import GenBCodeOps.addFlagIf
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2231,6 +2231,8 @@ object desugar {
New(ref(defn.RepeatedAnnot.typeRef), Nil :: Nil))
else if op.name == nme.CC_REACH then
Apply(ref(defn.Caps_reachCapability), t :: Nil)
else if op.name == nme.CC_READONLY then
Apply(ref(defn.Caps_readOnlyCapability), t :: Nil)
else
assert(ctx.mode.isExpr || ctx.reporter.errorsReported || ctx.mode.is(Mode.Interactive), ctx.mode)
Select(t, op.name)
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
*/
def isVariableOrGetter(tree: Tree)(using Context): Boolean = {
def sym = tree.symbol
def isVar = sym.is(Mutable)
def isVar = sym.isMutableVarOrAccessor
def isGetter =
mayBeVarGetter(sym) && sym.owner.info.member(sym.name.asTermName.setterName).exists

Expand Down
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {

case class Var()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Mutable)

case class Mut()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Mutable)

case class Implicit()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Implicit)

case class Given()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Given)
Expand Down Expand Up @@ -332,6 +334,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {

def isEnumCase: Boolean = isEnum && is(Case)
def isEnumClass: Boolean = isEnum && !is(Case)
def isMutableVar: Boolean = is(Mutable) && mods.exists(_.isInstanceOf[Mod.Var])
}

@sharable val EmptyModifiers: Modifiers = Modifiers()
Expand Down
5 changes: 0 additions & 5 deletions compiler/src/dotty/tools/dotc/cc/CaptureAnnotation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ case class CaptureAnnotation(refs: CaptureSet, boxed: Boolean)(cls: Symbol) exte
if (this.refs eq refs) && (this.boxed == boxed) then this
else CaptureAnnotation(refs, boxed)(cls)

override def sameAnnotation(that: Annotation)(using Context): Boolean = that match
case CaptureAnnotation(refs, boxed) =>
this.refs == refs && this.boxed == boxed && this.symbol == that.symbol
case _ => false

override def mapWith(tm: TypeMap)(using Context) =
val elems = refs.elems.toList
val elems1 = elems.mapConserve(tm)
Expand Down
Loading
Loading