Skip to content

Commit 30a53ef

Browse files
committed
Reorganize retains annotation classes
Since they are just backup syntax, no need to put them in the scala package.
1 parent 0ce75e1 commit 30a53ef

26 files changed

+85
-59
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1813,7 +1813,7 @@ object desugar {
18131813
// convert `{refs} T` to `T @retains refs`
18141814
// `{refs}-> T` to `-> (T @retainsByName refs)`
18151815
def annotate(annotName: TypeName, tp: Tree) =
1816-
Annotated(tp, New(scalaDot(annotName), List(refs)))
1816+
Annotated(tp, New(scalaAnnotationDot(annotName), List(refs)))
18171817
parent match
18181818
case ByNameTypeTree(restpt) =>
18191819
cpy.ByNameTypeTree(parent)(annotate(tpnme.retainsByName, restpt))

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,8 +1017,8 @@ class Definitions {
10171017
@tu lazy val VarargsAnnot: ClassSymbol = requiredClass("scala.annotation.varargs")
10181018
@tu lazy val SinceAnnot: ClassSymbol = requiredClass("scala.annotation.since")
10191019
@tu lazy val RequiresCapabilityAnnot: ClassSymbol = requiredClass("scala.annotation.internal.requiresCapability")
1020-
@tu lazy val RetainsAnnot: ClassSymbol = requiredClass("scala.retains")
1021-
@tu lazy val RetainsByNameAnnot: ClassSymbol = requiredClass("scala.retainsByName")
1020+
@tu lazy val RetainsAnnot: ClassSymbol = requiredClass("scala.annotation.retains")
1021+
@tu lazy val RetainsByNameAnnot: ClassSymbol = requiredClass("scala.annotation.retainsByName")
10221022

10231023
@tu lazy val JavaRepeatableAnnot: ClassSymbol = requiredClass("java.lang.annotation.Repeatable")
10241024

library/src-bootstrapped/scala/Retains.scala

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package scala.annotation
2+
3+
/** An annotation that indicates capture of a set of references under -Ycc.
4+
*
5+
* T @retains(x, y, z)
6+
*
7+
* is the internal representation used for the capturing type
8+
*
9+
* {x, y, z} T
10+
*
11+
* The annotation can also be written explicitly if one wants to avoid the
12+
* non-standard capturing type syntax.
13+
*/
14+
@experimental class retains(xs: Any*) extends annotation.StaticAnnotation
15+

library/src-bootstrapped/scala/retainsByName.scala renamed to library/src-bootstrapped/scala/annotation/retainsByName.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
package scala
2-
import annotation.experimental
1+
package scala.annotation
32

43
/** An annotation that indicates capture of an enclosing by-name type
54
*/

tests/neg-custom-args/captures/capt-depfun.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import annotation.retains
12
class C
23
type Cap = C @retains(*)
34

tests/neg-custom-args/captures/capt-depfun2.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import annotation.retains
12
class C
23
type Cap = C @retains(*)
34

tests/neg-custom-args/captures/capt-test.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import annotation.retains
12
import language.experimental.erasedDefinitions
23

34
class CT[E <: Exception]

tests/neg-custom-args/captures/capt-wf-typer.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import annotation.retains
12
class C
23
type Cap = {*} C
34

tests/neg-custom-args/captures/capt1.check

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:3:2 ------------------------------------------
2-
3 | () => if x == null then y else y // error
1+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:4:2 ------------------------------------------
2+
4 | () => if x == null then y else y // error
33
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44
| Found: {x} () -> ? C
55
| Required: () -> C
66
|
77
| longer explanation available when compiling with `-explain`
8-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:6:2 ------------------------------------------
9-
6 | () => if x == null then y else y // error
8+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:7:2 ------------------------------------------
9+
7 | () => if x == null then y else y // error
1010
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1111
| Found: {x} () -> ? C
1212
| Required: Matchable
1313
|
1414
| longer explanation available when compiling with `-explain`
15-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:13:2 -----------------------------------------
16-
13 | def f(y: Int) = if x == null then y else y // error
15+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:14:2 -----------------------------------------
16+
14 | def f(y: Int) = if x == null then y else y // error
1717
| ^
1818
| Found: {x} Int -> Int
1919
| Required: Matchable
20-
14 | f
20+
15 | f
2121
|
2222
| longer explanation available when compiling with `-explain`
23-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:20:2 -----------------------------------------
24-
20 | class F(y: Int) extends A: // error
23+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:21:2 -----------------------------------------
24+
21 | class F(y: Int) extends A: // error
2525
| ^
2626
| Found: {x} A
2727
| Required: A
28-
21 | def m() = if x == null then y else y
29-
22 | F(22)
28+
22 | def m() = if x == null then y else y
29+
23 | F(22)
3030
|
3131
| longer explanation available when compiling with `-explain`
32-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:25:2 -----------------------------------------
33-
25 | new A: // error
32+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:26:2 -----------------------------------------
33+
26 | new A: // error
3434
| ^
3535
| Found: {x} A
3636
| Required: A
37-
26 | def m() = if x == null then y else y
37+
27 | def m() = if x == null then y else y
3838
|
3939
| longer explanation available when compiling with `-explain`
40-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:31:24 ----------------------------------------
41-
31 | val z2 = h[() -> Cap](() => x) // error
40+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:32:24 ----------------------------------------
41+
32 | val z2 = h[() -> Cap](() => x) // error
4242
| ^^^^^^^
4343
| Found: {x} () -> {*} C
4444
| Required: () -> box {*} C
4545
|
4646
| longer explanation available when compiling with `-explain`
47-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:32:5 -----------------------------------------
48-
32 | (() => C()) // error
47+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/capt1.scala:33:5 -----------------------------------------
48+
33 | (() => C()) // error
4949
| ^^^^^^^^^
5050
| Found: ? () -> {*} C
5151
| Required: () -> box {*} C

0 commit comments

Comments
 (0)