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 3rd attempt #22588

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
62c7494
Elide capabilities implied by Capability subtypes when printing
odersky Dec 6, 2024
870ba3a
Add Mutable classes and ReadOnly capabilities
odersky Jan 10, 2025
1ba5ac2
Drop special handling of functions with pure arguments in Existential…
odersky Dec 15, 2024
5e132ad
Implement fresh capabilities
odersky Jan 11, 2025
811700a
Separation checking for applications
odersky Jan 11, 2025
602b891
Separation checking for blocks
odersky Jan 12, 2025
2aeaad7
Address review comments
odersky Jan 19, 2025
0a7596b
Use deep capturesets for separation checking.
odersky Jan 20, 2025
6b56d32
Cache derived reach, readOnly, and maybe capabilities
odersky Jan 20, 2025
cb8a1d0
Avoid forming intersections of capture sets on refined type lookup
odersky Jan 21, 2025
d99cbd1
Check separation of different parts of a declared type.
odersky Jan 24, 2025
845adbf
Check that hidden parameters are annotated @consume
odersky Jan 25, 2025
ddd4afa
Check that only @consume parameters flow to @consume parameters
odersky Jan 26, 2025
dd4bde6
Check that SharedCapabilities don't capture `cap`.
odersky Jan 26, 2025
65e6d5e
Turn separation checking on by default
odersky Jan 26, 2025
3bd3fd0
Make sure fresh results of methods only hide local refs
odersky Jan 27, 2025
6a421b0
Make sure parameters are not used again after they are consumed
odersky Jan 28, 2025
3223fb3
Check accesses to non-local this in hidden sets
odersky Jan 28, 2025
f907eee
Check that @consumed prefix capabilities are not re-used
odersky Jan 29, 2025
d79d5ff
Allow SharableCapablity anywhere on a path
odersky Jan 30, 2025
1a05c96
Polishings
odersky Jan 31, 2025
5ec7351
Polish and document separation checker.
odersky Feb 1, 2025
fe20f2c
Address review comments
odersky Feb 5, 2025
3b32fe6
Fix handling paths extending SharedCapabiolity
odersky Feb 9, 2025
268e837
Streamline deepCaptureSet
odersky Feb 9, 2025
134108f
chore: try with JVM 8
hamzaremmal Feb 12, 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:

steps:
- name: Set JDK 17 as default
run: echo "/usr/lib/jvm/java-17-openjdk-amd64/bin" >> $GITHUB_PATH
run: echo "/usr/lib/jvm/java-8-openjdk-amd64/bin" >> $GITHUB_PATH

- name: Reset existing repo
run: |
Expand Down
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 @@ -759,7 +759,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