Skip to content

Exclusive capabilities #22218

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

Merged
merged 23 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
22cb87b
Elide capabilities implied by Capability subtypes when printing
odersky Dec 6, 2024
216973e
Add Mutable classes and ReadOnly capabilities
odersky Jan 10, 2025
234d0dc
Drop special handling of functions with pure arguments in Existential…
odersky Dec 15, 2024
a239bfa
Implement fresh capabilities
odersky Jan 11, 2025
d211bf9
Separation checking for applications
odersky Jan 11, 2025
fd327e3
Separation checking for blocks
odersky Jan 12, 2025
b0be75b
Address review comments
odersky Jan 19, 2025
c377f49
Use deep capturesets for separation checking.
odersky Jan 20, 2025
1cdb21b
Cache derived reach, readOnly, and maybe capabilities
odersky Jan 20, 2025
937b8af
Avoid forming intersections of capture sets on refined type lookup
odersky Jan 21, 2025
438ea60
Check separation of different parts of a declared type.
odersky Jan 24, 2025
c1f2542
Check that hidden parameters are annotated @consume
odersky Jan 25, 2025
9ca1776
Check that only @consume parameters flow to @consume parameters
odersky Jan 26, 2025
564c847
Check that SharedCapabilities don't capture `cap`.
odersky Jan 26, 2025
94fcabc
Turn separation checking on by default
odersky Jan 26, 2025
e229807
Make sure fresh results of methods only hide local refs
odersky Jan 27, 2025
84b5bff
Make sure parameters are not used again after they are consumed
odersky Jan 28, 2025
c1ad0c1
Check accesses to non-local this in hidden sets
odersky Jan 28, 2025
65a1301
Check that @consumed prefix capabilities are not re-used
odersky Jan 29, 2025
9f40649
Allow SharableCapablity anywhere on a path
odersky Jan 30, 2025
b0628d1
Polishings
odersky Jan 31, 2025
813c585
Polish and document separation checker.
odersky Feb 1, 2025
a41c10f
Address review comments
odersky Feb 5, 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 @@ -2243,6 +2243,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
Loading
Loading