Skip to content

Commit 5cdb3da

Browse files
committed
Drop collective extensions from tests and docs
1 parent 00cc25d commit 5cdb3da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+88
-123
lines changed

compiler/test-resources/repl/i8716_i8717

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ scala>extension { }
22
1 |extension { }
33
|^
44
|anonymous instance must implement a type or have at least one extension method
5-
scala> extension as on
6-
1 | extension as on
5+
scala> extension as
6+
1 | extension as
77
| ^
88
| '(' expected, but eof found
9-
scala> extension as on (s
10-
1 | extension as on (s
9+
scala> extension as (s
10+
1 | extension as (s
1111
| ^
1212
| ':' expected, but eof found
13-
scala> extension as on (s: String) { def expand = ??? }
13+
scala> extension as (s: String) { def expand = ??? }
1414
// defined object as

docs/docs/reference/contextual/relationship-implicits.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,6 @@ The synthesized type names are formed from
6161
Tuples are treated as transparent, i.e. a type `F[(X, Y)]` would get the synthesized name
6262
`F_X_Y`. Directly implemented function types `A => B` are represented as `A_to_B`. Function types used as arguments to other type constructors are represented as `Function`.
6363

64-
### Anonymous Collective Extensions
65-
66-
Anonymous collective extensions also get compiler synthesized names, which are formed from
67-
68-
- the prefix `extension_`
69-
- the name of the first defined extension method
70-
- the simple name of the first parameter type of this extension method
71-
- the simple name(s) of the toplevel argument type constructors to this type.
72-
73-
For example, the extension
74-
```scala
75-
extension on [T] (xs: List[T]) {
76-
def second = ...
77-
}
78-
```
79-
gets the synthesized name `extension_second_List_T`.
80-
8164
### Given Clauses
8265

8366
Given clauses correspond largely to Scala-2's implicit parameter clauses. E.g.

docs/docs/reference/other-new-features/indentation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ type T = A:
123123
given [T] with Ord[T] as Ord[List[T]]:
124124
def compare(x: List[T], y: List[T]) = ???
125125

126-
extension on (xs: List[Int]):
126+
extension (xs: List[Int]):
127127
def second: Int = xs.tail.head
128128

129129
new A:
@@ -256,7 +256,7 @@ For instance, the following end markers are all legal:
256256
end given
257257
end C
258258

259-
extension on (x: C):
259+
extension (x: C):
260260
def ff: String = x.f ++ x.f
261261
end extension
262262

docs/docs/reference/other-new-features/opaques.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ object Logarithms {
2121
}
2222

2323
// Extension methods define opaque types' public APIs
24-
extension logarithmOps on (x: Logarithm) {
24+
extension (x: Logarithm) {
2525
def toDouble: Double = math.exp(x)
2626
def + (y: Logarithm): Logarithm = Logarithm(math.exp(x) + math.exp(y))
2727
def * (y: Logarithm): Logarithm = x + y
@@ -36,8 +36,7 @@ Or in other words, within the scope it is treated as type alias, but this is opa
3636
where in consequence `Logarithm` is seen as an abstract type and has nothing to do with `Double`.
3737

3838
The public API of `Logarithm` consists of the `apply` and `safe` methods defined in the companion object.
39-
They convert from `Double`s to `Logarithm` values. Moreover, a collective extension `logarithmOps` provides the extension methods `toDouble` that converts the other way,
40-
and operations `+` and `*` on `Logarithm` values.
39+
They convert from `Double`s to `Logarithm` values. Moreover, an operation `toDouble` that converts the other way, and operations `+` and `*` are defined as extension methods on `Logarithm` values.
4140
The following operations would be valid because they use functionality implemented in the `Logarithms` object.
4241

4342
```scala

tests/neg/anonymous-instance-cannot-be-empty.check

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
object Test {
2-
extension on[T] (t: T) { } // error
2+
extension [T] (t: T) { } // error
33
}

tests/neg/extension-cannot-have-type.check

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
object Test {
2-
extension on[T] (t: T) {
3-
def f[U](u: U): T = ??? // error : extension method cannot have type params
2+
extension [T] (t: T) {
3+
def f[U](u: U): T = ??? // error: extension method cannot have type parameters here, all type parameters go after `extension`
44
}
55
}

tests/neg/extension-method-not-allowed.check

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
object Test {
2-
extension on[T] (t: T) {
2+
extension [T] (t: T) {
33
extension (c: T) def f: T = ??? // error : No extension method allowed here
44
}
55
}

0 commit comments

Comments
 (0)