Skip to content

Commit 698810d

Browse files
committed
Make cap an object instead of a val, change how it is printed
1 parent 97bfef9 commit 698810d

File tree

5 files changed

+7
-16
lines changed

5 files changed

+7
-16
lines changed

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,11 @@ class PlainPrinter(_ctx: Context) extends Printer {
195195
homogenize(tp) match {
196196
case tp: TypeType =>
197197
toTextRHS(tp)
198+
case tp: TermRef if tp.isCap =>
199+
toTextCaptureRef(tp)
198200
case tp: TermRef
199201
if !tp.denotationIsCurrent
200202
&& !homogenizedView // always print underlying when testing picklers
201-
&& !tp.isCap
202203
|| tp.symbol.is(Module)
203204
|| tp.symbol.name == nme.IMPORT =>
204205
toTextRef(tp) ~ ".type"

library/src/scala/caps/package.scala

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,7 @@ trait Capability extends Any
2727

2828
/** The universal capture reference. */
2929
@experimental
30-
val cap: Capability = new Capability() {}
31-
32-
/** The universal capture reference (deprecated) */
33-
@deprecated("Use `cap` instead")
34-
@experimental
35-
val `*`: Capability = cap
36-
37-
@deprecated("Use `Capability` instead")
38-
@experimental
39-
type Cap = Capability
30+
object cap extends Capability
4031

4132
/** Marker trait for classes with methods that requires an exclusive reference. */
4233
@experimental

tests/neg-custom-args/captures/cc-this2.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- Error: tests/neg-custom-args/captures/cc-this2/D_2.scala:3:8 --------------------------------------------------------
33
3 | this: D^ => // error
44
| ^^
5-
|reference (scala.caps.cap : scala.caps.Capability) captured by this self type is not included in the allowed capture set {} of pure base class class C
5+
| reference cap captured by this self type is not included in the allowed capture set {} of pure base class class C
66
-- [E058] Type Mismatch Error: tests/neg-custom-args/captures/cc-this2/D_2.scala:2:6 -----------------------------------
77
2 |class D extends C: // error
88
| ^

tests/neg-custom-args/captures/exception-definitions.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/neg-custom-args/captures/exception-definitions.scala:3:8 -----------------------------------------------
22
3 | self: Err^ => // error
33
| ^^^^
4-
|reference (scala.caps.cap : scala.caps.Capability) captured by this self type is not included in the allowed capture set {} of pure base class class Throwable
4+
|reference cap captured by this self type is not included in the allowed capture set {} of pure base class class Throwable
55
-- Error: tests/neg-custom-args/captures/exception-definitions.scala:7:12 ----------------------------------------------
66
7 | val x = c // error
77
| ^

tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ val experimentalDefinitionInLibrary = Set(
4343
"scala.caps.consume",
4444
"scala.caps.internal",
4545
"scala.caps.internal$",
46-
"scala.caps.package$package$.*",
47-
"scala.caps.package$package$.Cap",
48-
"scala.caps.package$package$.cap",
46+
"scala.caps.cap",
47+
"scala.caps.cap$",
4948
"scala.caps.unsafe",
5049
"scala.caps.unsafe$",
5150
"scala.caps.use",

0 commit comments

Comments
 (0)