@@ -68,7 +68,7 @@ package scala
68
68
trait Phantom { // only an `object` can extend this trait
69
69
protected final type Any // not a subtype of scala.Any
70
70
protected final type Nothing // subtype of every subtype of this.Any
71
- protected final def assume : this .Nothig
71
+ protected final def assume : this .Nothing
72
72
}
73
73
```
74
74
@@ -81,8 +81,8 @@ New phantom types can be defined using `type XYZ <: OtherPhantom` (where `>: MyP
81
81
will be inferred), this would be the equivalent of ` class XYZ extends OtherClass ` on a types
82
82
only (no runtime definitions). Or aliased with ` type MyAny = OtherPhantom ` . Within ` MyPhantoms `
83
83
it is possible to refer to ` MyPhantoms.Any ` and ` MyPhantoms.Nothing ` with ` this.Any ` and
84
- ` this.Nothing ` (or just ` Any ` and ` Nothing ` but not recommended). Using this we will define
85
- four the four phantoms: ` Inky ` , ` Blinky ` , ` Pinky ` and ` Clyde ` .
84
+ ` this.Nothing ` (or just ` Any ` and ` Nothing ` but not recommended). Using this we will define
85
+ the four phantoms: ` Inky ` , ` Blinky ` , ` Pinky ` and ` Clyde ` .
86
86
87
87
``` scala
88
88
object MyPhantoms extends Phantom {
@@ -94,7 +94,7 @@ object MyPhantoms extends Phantom {
94
94
```
95
95
96
96
Values of phantom type can be created using the ` protected def assume ` . This value can be
97
- used as a value of this phantom type as it's type is ` this.Nothig ` (or ` MyPhantoms.Nothing ` ).
97
+ used as a value of this phantom type as it's type is ` this.Nothing ` (or ` MyPhantoms.Nothing ` ).
98
98
Usually this value will be used to define a ` implicit def ` that returns the phantom with a more
99
99
precise type. In our example we will only create values of type ` Pinky ` and ` Clyde `
100
100
@@ -109,7 +109,7 @@ object MyPhantoms extends Phantom {
109
109
110
110
### Using the phantoms
111
111
112
- From the user of the phantom type there is almost no difference, except for stronger type guarantees.
112
+ For the user of the phantom type there is almost no difference, except for stronger type guarantees.
113
113
We can look at the following simple application:
114
114
115
115
``` scala
@@ -123,7 +123,7 @@ object MyApp {
123
123
}
124
124
```
125
125
126
- Note given the way we defined the phantoms it is impossible to call the ` hide ` as we did not
126
+ Note that given the way we defined the phantoms it is impossible to call ` hide ` as we did not
127
127
expose any value of type ` Blinky ` to the user. We cannot call ` hide(MyPhantoms.assume) ` as
128
128
` assume ` is protected, ` hide(null.asInstanceOf[Blinky]) ` does not compile because it is impossible
129
129
to cast to a phantom and ` hide(throw new Exception) ` (or ` hide(???) ` ) does not compile as ` throw ` of
0 commit comments