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
*`def foo(x: T): U` cannot be overridden by `def foo(erased x: T): U` and vice-versa.
40
40
41
41
8. Type Restrictions
42
-
* Polymorphic functions 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.
42
+
* 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.
In some cases we would expect all instances of a trait to be erased. For instance, one could argue that it does not make sense to ever have a `CanSerialize[T]` instance at runtime. In that case we
146
146
can make `CanSerialize` extend from a new trait `compiletimetime.Erased` and avoid the explicit
147
-
`erased` modifiers in erased parameters and vals. Here is an alternative version our example using this scheme:
147
+
`erased` modifiers in erased parameters and vals. Here is an alternative version of our example using this scheme:
148
148
```scala
149
149
classCanSerialize[T] extends compiletime.Erased
150
150
...
@@ -157,7 +157,7 @@ using clause `(using CanSerialize[T])` which gets implicitly tagged with `erased
157
157
158
158
## Uses of `Erased` in existing Code
159
159
160
-
- The `CanThrow[T]`typeclass is used to declare that an can be thrown. The compiler generates a `CanThrow[E]` instances for exceptions that are handled in a `try`. Methods take an implicit `CanThrow[E]` parameter to indicate that they might throw exception `E`. `CanThrow` is declared to be an `Erased` capability class, so no actual evidence of `CanThrow` remains at run-time.
160
+
- The `CanThrow[T]`type class is used to declare that an exception can be thrown. The compiler generates a `CanThrow[E]` instances for exceptions that are handled in a `try`. Methods take an implicit `CanThrow[E]` parameter to indicate that they might throw exception `E`. `CanThrow` is declared to be an `Erased` capability class, so no actual evidence of `CanThrow` remains at run-time.
161
161
162
162
- The `CanEqual` evidence of [multiversal equality](../contextual/multiversal-equality.html) checks that two types can be compared. The actual comparison is done by the universal `equals` method of class `Object` or an overriding instance, it does not rely on the `CanEqual` value.
163
163
So far, `CanEqual` is handled specially in the compiler. With erased definitions, we could
0 commit comments