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
1.`erased` is a soft modifier. It can appear in a `val` definition or in a parameter.
10
+
*`erased` cannot appear in a `lazy``val` definition.
11
+
*`erased`_can_ appear for a parameterless given that expands to a value
12
+
definition. In that case the `given` is expanded to a non-lazy `val`.
13
+
*`erased` cannot appear in a mutable `var` definition.
14
+
*`erased` cannot appear in an `object` definition.
10
15
11
-
2. A reference to an `erased` value can only be used in an *erased context*:
16
+
2. Values that have a type that extends the `scala.compiletime.Erased` trait are
17
+
implicitly `erased`.
18
+
19
+
* The restrictions of point (1) apply.
20
+
* Parameterless givens are treated like values.
21
+
* Mutable variables cannot have a time that extends `scala.compiletime.Erased`.
22
+
23
+
3. A reference to an `erased` value can only be used in an *erased context*:
12
24
* Inside the expression of an argument to an `erased` parameter
13
25
* Inside the body of an `erased``val`
14
26
* Inside the path of a dependent type expression
15
27
16
-
3.`erased` can also be used in a function type, e.g.
28
+
4.`erased` can also be used in a function type, e.g.
17
29
18
30
*`(erased T1, T2) => R`
19
31
*`(x: T1, y: erased T2) ?=> T`
20
32
21
33
Note that there is no subtype relation between `(erased T) => R` and `T => R` (or `(erased T) ?=> R` and `T ?=> R`). The `erased` parameters must match exactly in their respective positions.
22
34
23
-
4. Eta expansion
35
+
5. Eta expansion
24
36
25
37
if `def f(erased x: T): U` then `f: (erased T) => U`.
26
38
27
-
5. Erasure semantics
39
+
6. Erasure semantics
28
40
* All `erased` parameters are removed from the function
29
41
* All arguments to `erased` parameters are not passed to the function
30
42
* All `erased` value definitions are removed
31
43
* All `erased` argument types are removed from a function type
32
44
33
-
6. Overloading
45
+
7. Overloading
34
46
35
47
Method with `erased` parameters will follow the normal overloading constraints after erasure.
36
48
37
-
7. Overriding
49
+
8. Overriding
38
50
* Member definitions overriding each other must both be `erased` or not be `erased`.
39
51
*`def foo(x: T): U` cannot be overridden by `def foo(erased x: T): U` and vice-versa.
40
52
41
-
8. Type Restrictions
53
+
9. Type Restrictions
42
54
* Polymorphic function literals with erased parameters are currently not supported, and will be rejected by the compiler. This is purely an implementation restriction, and might be lifted in the future.
0 commit comments