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 revised #22544

Merged
merged 23 commits into from
Feb 7, 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
d038367
Elide capabilities implied by Capability subtypes when printing
odersky Dec 6, 2024
6ddafb6
Add Mutable classes and ReadOnly capabilities
odersky Jan 10, 2025
779f913
Drop special handling of functions with pure arguments in Existential…
odersky Dec 15, 2024
7561432
Implement fresh capabilities
odersky Jan 11, 2025
052ffbc
Separation checking for applications
odersky Jan 11, 2025
dd422d1
Separation checking for blocks
odersky Jan 12, 2025
a553277
Address review comments
odersky Jan 19, 2025
bbce87d
Use deep capturesets for separation checking.
odersky Jan 20, 2025
4e1094f
Cache derived reach, readOnly, and maybe capabilities
odersky Jan 20, 2025
b3b524c
Avoid forming intersections of capture sets on refined type lookup
odersky Jan 21, 2025
fbb901e
Check separation of different parts of a declared type.
odersky Jan 24, 2025
ac7780e
Check that hidden parameters are annotated @consume
odersky Jan 25, 2025
03f2b2a
Check that only @consume parameters flow to @consume parameters
odersky Jan 26, 2025
ca5c4cf
Check that SharedCapabilities don't capture `cap`.
odersky Jan 26, 2025
5125481
Turn separation checking on by default
odersky Jan 26, 2025
82f3e16
Make sure fresh results of methods only hide local refs
odersky Jan 27, 2025
e47dae5
Make sure parameters are not used again after they are consumed
odersky Jan 28, 2025
53adf90
Check accesses to non-local this in hidden sets
odersky Jan 28, 2025
2bf473d
Check that @consumed prefix capabilities are not re-used
odersky Jan 29, 2025
7b3d3f4
Allow SharableCapablity anywhere on a path
odersky Jan 30, 2025
0a37cc1
Polishings
odersky Jan 31, 2025
d684f60
Polish and document separation checker (2)
odersky Feb 7, 2025
071bf19
Address review comments
odersky Feb 7, 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