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