@@ -147,10 +147,10 @@ object Test {
147
147
Rules
148
148
-----
149
149
150
- 1 ) The ` erased ` modifier can appear:
151
- * At the start of a parameter block of a method, function or class
152
- * In a method definition
153
- * In a ` val ` definition (but not ` lazy val ` or ` var ` )
150
+ 1 . The ` erased ` modifier can appear:
151
+ * At the start of a parameter block of a method, function or class
152
+ * In a method definition
153
+ * In a ` val ` definition (but not ` lazy val ` or ` var ` )
154
154
155
155
``` scala
156
156
erased val x = ...
@@ -164,33 +164,40 @@ def h(x: erased Int => Int) = ...
164
164
class K (erased x : Int ) { ... }
165
165
```
166
166
167
- 2 ) A reference to an ` erased ` definition can only be used
168
- * Inside the expression of argument to an ` erased ` parameter
169
- * Inside the body of an ` erased ` ` val ` or ` def `
170
167
171
- 3 ) Functions
172
- * ` (erased x1: T1, x2: T2, ..., xN: TN) => y : (erased T1, T2, ..., TN) => R `
173
- * ` (implicit erased x1: T1, x2: T2, ..., xN: TN) => y : (implicit erased T1, T2, ..., TN) => R `
174
- * ` implicit erased T1 => R <:< erased T1 => R `
175
- * ` (implicit erased T1, T2) => R <:< (erased T1, T2) => R `
176
- * ...
168
+ 2 . A reference to an ` erased ` definition can only be used
169
+ * Inside the expression of argument to an ` erased ` parameter
170
+ * Inside the body of an ` erased ` ` val ` or ` def `
171
+
172
+
173
+ 3 . Functions
174
+ * ` (erased x1: T1, x2: T2, ..., xN: TN) => y : (erased T1, T2, ..., TN) => R `
175
+ * ` (implicit erased x1: T1, x2: T2, ..., xN: TN) => y : (implicit erased T1, T2, ..., TN) => R `
176
+ * ` implicit erased T1 => R <:< erased T1 => R `
177
+ * ` (implicit erased T1, T2) => R <:< (erased T1, T2) => R `
178
+ * ...
177
179
178
180
Note that there is no subtype relation between ` erased T => R ` and ` T => R ` (or ` implicit erased T => R ` and ` implicit T => R ` )
179
181
180
- 4 ) Eta expansion
182
+
183
+ 4 . Eta expansion
184
+
181
185
if ` def f(erased x: T): U ` then ` f: (erased T) => U ` .
182
186
183
187
184
- 5 ) Erasure Semantics
185
- * All ` erased ` paramters are removed from the function
186
- * All argument to ` erased ` paramters are not passed to the function
187
- * All ` erased ` definitions are removed
188
- * All ` (erased T1, T2, ..., TN) => R ` and ` (implicit erased T1, T2, ..., TN) => R ` become ` () => R `
188
+ 5 . Erasure Semantics
189
+ * All ` erased ` paramters are removed from the function
190
+ * All argument to ` erased ` paramters are not passed to the function
191
+ * All ` erased ` definitions are removed
192
+ * All ` (erased T1, T2, ..., TN) => R ` and ` (implicit erased T1, T2, ..., TN) => R ` become ` () => R `
193
+
194
+
195
+ 6 . Overloading
189
196
190
- 6 ) Overloading
191
197
Method with ` erased ` parameters will follow the normal overloading constraints after erasure.
192
198
193
- 7 ) Overriding
194
- * Member definitions overidding each other must both be ` erased ` or not be ` erased `
195
- * ` def foo(x: T): U ` cannot be overriden by ` def foo(erased x: T): U ` an viceversa
199
+
200
+ 7 . Overriding
201
+ * Member definitions overidding each other must both be ` erased ` or not be ` erased `
202
+ * ` def foo(x: T): U ` cannot be overriden by ` def foo(erased x: T): U ` an viceversa
196
203
0 commit comments