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
Match types amendment: extractors follow aliases and singletons
The existing spec uses as a legal example:
```
class Base {
type Y
}
type YExtractor[t] = Base { type Y = t }
```
And we are allowed to define:
```
type ExtractY[B <: Base] = B match
case YExtractor[t] => t
```
However, with the existing spec, extraction does not always work as one might
expect:
```
class Sub1 extends Base:
type Y = Alias
type Alias = Int
class Sub2[T] extends Base:
type Y = T
class Sub3 extends Base:
val elem: Sub1 = new Sub1
type Y = elem.Y
ExtractY[Base { type Y = Int }] // OK
ExtractY[Sub1] // error
ExtractY[Sub2[Int]] // error
ExtractY[Sub3] // error
```
What's going on here is that when extracting a type `Y` from a non-stable
prefix `X`, the spec mandates that we generate a skolem `q` and use that as a
prefix to lookup the underlying type of `Y`. Extraction only succeeds if the
underlying type does not refer to `q`. For example, for `ExtractY[Sub1]` we
have `q.Y` with underlying type `q.Alias` which is rejected since it refers to
`q`.
We amend the spec to follow aliases and singleton types in the extracted type,
so that `q.Alias` can be dealiased to `Int` which is then accepted as a valid
extracted type.
0 commit comments