You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/reference/common-declarations.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ class FlatText(str: String) extends Text {
29
29
}
30
30
```
31
31
32
-
The `common`definition of`fromString` is abstract in trait `Text`. It is defined in the implementing companion object of `FlatText`. By contrast, the `fromStrings` method in trait Text is concrete, with an implementation referring to the abstract `fromString`. It is inherited by the companion object `FlatText`. So the following are legal:
32
+
The `common`method`fromString` is abstract in trait `Text`. It is defined in the implementing companion object of `FlatText`. By contrast, the `fromStrings` method in trait Text is concrete, with an implementation referring to the abstract `fromString`. It is inherited by the companion object `FlatText`. So the following are legal:
33
33
34
34
```scala
35
35
valtxt1=FlatText.fromString("hello")
@@ -44,7 +44,7 @@ val erroneous = Text.fromStrings("hello", ", world") // error: not found
44
44
45
45
## The `Instance` type
46
46
47
-
In the previous example, the argument and result type of `concat` is just `Text`. So every implementation of `Text` has to be prepared to concatenate all possible implementatons of `Text`. Furthermore, we hide the concrete implementation type in the result type of `concat` and of the construction methods `fromString` and `fromStrings`. Sometimes we want a different design that specifyfies the actual implementation type instead of the base trait `Text`. We can refer to this type using the predefined type `Instance`:
47
+
In the previous example, the argument and result type of `concat` is just `Text`. So every implementation of `Text` has to be prepared to concatenate all possible implementatons of `Text`. Furthermore, we hide the concrete implementation type in the result type of `concat` and of the construction methods `fromString` and `fromStrings`. Sometimes we want a different design that specifies the actual implementation type instead of the base trait `Text`. We can refer to this type using the predefined type `Instance`:
48
48
49
49
```scala
50
50
traitText {
@@ -114,8 +114,8 @@ the object that implements the `common` definitions.
114
114
## Translation
115
115
116
116
The translation of a trait `T` that defines `common` declarations `common D1, ..., common Dn`
117
-
and extends traits with common declarations `P1`, ..., Pn` is as follows:
118
-
All `common`definitions are put in a trait `T.Common` which is defined in `T`'s companion object:
117
+
and extends traits with common declarations `P1, ..., Pn` is as follows:
118
+
All `common`declarations are put in a trait `T.Common` which is defined in `T`'s companion object:
119
119
120
120
object T {
121
121
trait Common extends P1.Common with ... with Pn.Common { self =>
@@ -130,7 +130,7 @@ The trait inherits all `Common` traits associated with `T`'s parent traits. If n
130
130
given, it declares the `Instance` type as shown above. The trait `T` itself is expanded as follows:
131
131
132
132
trait T extends ... {
133
-
val `common`: `T.Common`
133
+
val `common`: T.Common
134
134
import `common`._
135
135
136
136
...
@@ -141,7 +141,7 @@ Any direct reference to `x.common` in the body of `T` is simply translated to
141
141
x.`common`
142
142
143
143
The translation of a class `C` that defines `common` declarations `common D1, ..., common Dn`
144
-
and extends traits with common declarations `P1`, ..., Pn` is as follows:
144
+
and extends traits with common declarations `P1, ..., Pn` is as follows:
145
145
All `common` definitions of the class itself are placed in `C`'s companion object, which also inherits all
146
146
`Common` traits of `C`'s parents. If `C` already defines a companion object, the synthesized parents
147
147
come after the explicitly declared ones, whereas the common definitions precede all explicitly given statements of the
0 commit comments