Skip to content

Commit 055beab

Browse files
committed
Enhancement: Introduce caps.Pure trait
This can replace the more obscure idiom of declaring a non-capturing self type.
1 parent 1b15fa6 commit 055beab

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

library/src/scala/caps.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ import annotation.experimental
1616
* avoids the error that would be raised when unboxing `*`.
1717
*/
1818
extension [T](x: T) def unsafeUnbox: T = x
19+
20+
/** Mixing in this trait forces a trait or class to be pure, i.e.
21+
* have no capabilities retained in its self type.
22+
*/
23+
trait Pure:
24+
this: Pure =>

project/MiMaFilters.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ object MiMaFilters {
1919
ProblemFilters.exclude[MissingClassProblem]("scala.runtime.stdLibPatches.language$experimental$pureFunctions$"),
2020
ProblemFilters.exclude[MissingClassProblem]("scala.runtime.stdLibPatches.language$experimental$captureChecking$"),
2121
ProblemFilters.exclude[MissingClassProblem]("scala.caps"),
22+
ProblemFilters.exclude[MissingClassProblem]("scala.caps$Pure"),
2223
)
2324
}

0 commit comments

Comments
 (0)