From 06526768f0f72f0cb75696bfcc9e4c249eebb60c Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 5 May 2025 16:50:49 +0200 Subject: [PATCH 1/3] Make caps.{Capability, Classifier, Shareable, Control} non-experimental These are all neccessary for boundary.Label --- compiler/src/dotty/tools/dotc/core/Definitions.scala | 4 ++-- library/src/scala/caps/package.scala | 4 ---- tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala | 4 ---- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index 030f14a73f1c..79fa0e94e06a 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -2112,8 +2112,8 @@ class Definitions { */ @tu lazy val ccExperimental: Set[Symbol] = Set( CapsModule, CapsModule.moduleClass, PureClass, - Caps_Capability, // TODO: Remove when Capability is stabilized - Caps_Classifier, Caps_SharedCapability, Caps_Control, Caps_ExclusiveCapability, Caps_Mutable, Caps_Read, + /* Caps_Classifier, Caps_SharedCapability, Caps_Control, -- already stable */ + Caps_ExclusiveCapability, Caps_Mutable, Caps_Read, RequiresCapabilityAnnot, captureRoot, Caps_CapSet, Caps_ContainsTrait, Caps_ContainsModule, Caps_ContainsModule.moduleClass, ConsumeAnnot, UseAnnot, ReserveAnnot, diff --git a/library/src/scala/caps/package.scala b/library/src/scala/caps/package.scala index 66f29ef174b1..77a1a5966c42 100644 --- a/library/src/scala/caps/package.scala +++ b/library/src/scala/caps/package.scala @@ -24,14 +24,12 @@ import annotation.{experimental, compileTimeOnly, retainsCap} * * Capability has exactly two subtraits: Shared and Exclusive. */ -@experimental sealed trait Capability extends Any /** A marker trait for classifier capabilities that can appear in `.only` * qualifiers. Capability classes directly extending `Classifier` are treated * as classifier capbilities */ -@experimental trait Classifier /** The universal capture reference. */ @@ -41,7 +39,6 @@ object cap extends Capability /** Marker trait for capabilities that can be safely shared in a concurrent context. * During separation checking, shared capabilities are not taken into account. */ -@experimental trait SharedCapability extends Capability, Classifier @experimental @@ -58,7 +55,6 @@ type Exclusive = ExclusiveCapability /** Base trait for capabilities that capture some continuation or return point in * the stack. Examples are exceptions, labels, Async, CanThrow. */ -@experimental trait Control extends SharedCapability, Classifier /** Marker trait for classes with methods that require an exclusive reference. */ diff --git a/tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala b/tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala index 4b356ffdada1..9effb37d5278 100644 --- a/tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala +++ b/tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala @@ -32,17 +32,13 @@ val experimentalDefinitionInLibrary = Set( "scala.annotation.retainsCap", "scala.Pure", "scala.caps.CapSet", - "scala.caps.Capability", - "scala.caps.Classifier", "scala.caps.Contains", "scala.caps.Contains$", "scala.caps.Contains$.containsImpl", "scala.caps.Exists", - "scala.caps.SharedCapability", "scala.caps.ExclusiveCapability", "scala.caps.Mutable", "scala.caps.Read", - "scala.caps.Control", "scala.caps.consume", "scala.caps.internal", "scala.caps.internal$", From 0ad0244bd1dda8d8c171bdaaefeb11c60758c914 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 11 Jul 2025 14:45:50 +0200 Subject: [PATCH 2/3] Add MiMa filter --- project/MiMaFilters.scala | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/project/MiMaFilters.scala b/project/MiMaFilters.scala index 0d93e5ea2942..7e97b1a3b8c4 100644 --- a/project/MiMaFilters.scala +++ b/project/MiMaFilters.scala @@ -28,6 +28,10 @@ object MiMaFilters { ProblemFilters.exclude[MissingClassProblem]("scala.annotation.internal.onlyCapability"), ProblemFilters.exclude[MissingFieldProblem]("scala.runtime.stdLibPatches.language#experimental.separationChecking"), ProblemFilters.exclude[MissingClassProblem]("scala.runtime.stdLibPatches.language$experimental$separationChecking$"), + ProblemFilters.exclude[MissingClassProblem]("scala.caps.Capability"), + ProblemFilters.exclude[MissingClassProblem]("scala.caps.Classifier"), + ProblemFilters.exclude[MissingClassProblem]("scala.caps.SharedCapability"), + ProblemFilters.exclude[MissingClassProblem]("scala.caps.Control"), ), // Additions since last LTS From 07142c2dd66a6d139d3f93b831412e5bec2e3550 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 12 Aug 2025 14:36:15 +0200 Subject: [PATCH 3/3] Add mentions of capture checking to affected traits --- library/src/scala/caps/package.scala | 29 +++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/library/src/scala/caps/package.scala b/library/src/scala/caps/package.scala index 77a1a5966c42..ff029fbbae9c 100644 --- a/library/src/scala/caps/package.scala +++ b/library/src/scala/caps/package.scala @@ -22,13 +22,17 @@ import annotation.{experimental, compileTimeOnly, retainsCap} * But even without capture checking, extending this trait can be useful for documenting the intended purpose * of a class. * - * Capability has exactly two subtraits: Shared and Exclusive. + * Capability has exactly two subtraits: [[SharedCapability Shared]] and [[ExclusiveCapability Exclusive]]. */ sealed trait Capability extends Any /** A marker trait for classifier capabilities that can appear in `.only` * qualifiers. Capability classes directly extending `Classifier` are treated - * as classifier capbilities + * as classifier capbilities. + * + * [[Classifier]] has a formal meaning when + * [[scala.language.experimental.captureChecking Capture Checking]] + * is turned on. It should not be used outside of capture checking. */ trait Classifier @@ -37,6 +41,10 @@ trait Classifier object cap extends Capability /** Marker trait for capabilities that can be safely shared in a concurrent context. + * + * [[SharedCapability]] has a formal meaning when + * [[scala.language.experimental.captureChecking Capture Checking]] + * is turned on. * During separation checking, shared capabilities are not taken into account. */ trait SharedCapability extends Capability, Classifier @@ -44,7 +52,13 @@ trait SharedCapability extends Capability, Classifier @experimental type Shared = SharedCapability -/** Marker trait for exclusive capabilities that are separation-checked +/** Marker trait for capabilities that should only be used by one concurrent process + * at a given time. For example, write-access to a shared mutable buffer. + * + * [[ExclusiveCapability]] has a formal meaning when + * [[scala.language.experimental.captureChecking Capture Checking]] + * is turned on. + * During separation checking, exclusive usage of marked capabilities will be enforced. */ @experimental trait ExclusiveCapability extends Capability, Classifier @@ -52,8 +66,13 @@ trait ExclusiveCapability extends Capability, Classifier @experimental type Exclusive = ExclusiveCapability -/** Base trait for capabilities that capture some continuation or return point in - * the stack. Examples are exceptions, labels, Async, CanThrow. +/** Marker trait for capabilities that capture some continuation or return point in + * the stack. Examples are exceptions, [[scala.util.boundary.Label labels]], [[scala.CanThrow CanThrow]] + * or Async contexts. + * + * [[Control]] has a formal meaning when + * [[scala.language.experimental.captureChecking Capture Checking]] + * is turned on. */ trait Control extends SharedCapability, Classifier