docs/_docs/reference/experimental/erased-defs-spec.md
erased is a soft modifier. It can appear in a val definition or in a parameter.
erased cannot appear in a lazy val definition.erased can appear for a parameterless given that expands to a value
definition. In that case the given is expanded to a non-lazy val.erased cannot appear in a call-by-name parameter.erased cannot appear in a mutable var definition.erased cannot appear in an object definition.Values or parameters that have a type that extends the scala.compiletime.Erased trait are
implicitly erased.
scala.compiletime.Erased.A reference to an erased value can only be used in an erased context:
erased parametererased valerased can also be used in a function type, e.g.
(erased T1, T2) => R(x: T1, y: erased T2) ?=> TNote 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.
Eta expansion
if def f(erased x: T): U then f: (erased T) => U.
Erasure semantics
erased parameters are removed from the functionerased parameters are not passed to the functionerased value definitions are removederased argument types are removed from a function typeOverloading
Method with erased parameters will follow the normal overloading constraints after erasure.
Overriding
erased or not be erased.def foo(x: T): U cannot be overridden by def foo(erased x: T): U and vice-versa.Type Restrictions