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
closes#21754
Allow for the `tracked` modifier to be used for `val` members of classes
and traits. `tracked` members and members inheriting from `tracked`
force the type of the member (or it's overriding member) to be as exact
as
possible. More precisely, it will will assign the `tracked` member the
infered type of the rhs. For instance, consider the following
definition:
```scala 3
trait F:
tracked val a: Int
tracked val b: Int
class N extends F:
val a = 22 // a.type =:= 22
val b: Int = 22 // b.type =:= Int
tracked val c = 22 // c.type =:= 22
```
Here, the `tracked` modifier ensures that the type of `a` in `N` is `22`
and not `Int`. But the type of `b` is `N` is `Int` since it's explicitly
declared as `Int`. `tracked` members can also be immediately
initialized, as in the case of `c`.
---------
Co-authored-by: Matt Bovel <[email protected]>
Co-authored-by: odersky <[email protected]>
It would be great to be able to declare abstract
tracked
members.tracked
members, when overridden, will keep their exact type.e.g. the following code should compile
The text was updated successfully, but these errors were encountered: