I can't find the equivalent SLS for Scala 3. I am trying to slowly get myself into the Scala 3 mindset and write new code - and refactor old when next changed - so that its translation to Scala 3 is straightforward. Certain current usecases of type projections came to as a (very) indirect result of avoiding volatile class members.
Asked
Active
Viewed 211 times
3
-
1@user `Int with String` is not a volatile type https://www.scala-lang.org/files/archive/spec/2.13/03-types.html#volatile-types – Dmytro Mitin Oct 05 '20 at 18:54
-
@user oh yes, they are at first. But ultimately the definition is simple, if a bit unclear in the SQL: if it has an abstract (type param, abstract type alias) upper bound B (but which still has some members, either due to having a concrete bound or through refinement), and it is refined with abstract declarations (`type T <: X`) 'overriding' an already present declaration, than it's volatile. Definitions like `type T = X` are ok, though. This probably applies to `def `s and `val`s, too, although I never had a need for that. 'Intersection' types count as abstract if any member is abstract. – Turin Oct 05 '20 at 20:52
-
@Dmytro Mytin Thanks, that was what I figured and why I asked. If you post it as an answer I will accept it. And sorry, must have missed that comment! – Turin Oct 05 '20 at 20:53
1 Answers
4
I'll copy my comment from here:
Volatile types is a Scala-2 thing. They were a workaround to avoid issues caused by unsoundness of type projections:
Cannot override a type with non-volatile upper bound
In Scala 3 (general) type projections are dropped
https://dotty.epfl.ch/docs/reference/dropped-features/type-projection.html

Dmytro Mitin
- 48,194
- 3
- 28
- 66
-
[What is Type Projection in Scala, and Why is it Unsound?](https://lptk.github.io/programming/2019/09/13/type-projection.html) [Make type projections safe instead of dropping them](https://github.com/lampepfl/dotty-feature-requests/issues/14) – Dmytro Mitin Nov 17 '20 at 22:52