Scala 2 allowed general type projection T#A
where T
is an arbitrary type and A
names a type member of T
. This turns out to be unsound (at least when combined with other Scala 3 features).
To remedy this, Scala 3 only allows type projection if T
is a concrete type (any type which is not abstract), an example for such a type would be a class type (class T
). A type is abstract if it is:
type T
without = SomeType
)[T]
)type T = SomeAbstractType
). There are no restriction on A
apart from the fact it has to be a member type of T
, for example a subclass (class T { class A }
).To rewrite code using type projections on abstract types, consider using path-dependent types or implicit parameters.
This restriction rules out the type-level encoding of a combinator calculus.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4