Skip to content

Don't flag match type aliases as unreducible #11847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 23, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Mar 22, 2021

If M[_] is a match type alias, it was rejected for being an unreducible
application of wildcard types. It is now accepted. I believe that is sound sinxe
it is simply an unreducible match type. The situation is not the same
as F[_] where F is an abstract type that can be refined in several ways
in subclasses.

Fixes #9999
Fixes #5592

odersky added 2 commits March 22, 2021 19:30
If `M[_]` is a match type alias, it was rejected for being an unreducible
application of wildcard types. It is now accepted. I believe that is sound
- this is siply an unreducible match type. The situation is not the same
as `F[_]` where `F` is an abstract type that can be refined in several ways
in subclasses.

Fixes scala#9999
Approximating type maps should not compute illegal unreducible wildcard applications.
Instead they should propagate the Range outwards

Fixes scala#5592
@smarter
Copy link
Member

smarter commented Mar 22, 2021

The situation is not the same as F[_] where F is an abstract type that can be refined in several ways in subclasses.

I don't think it's fundamentally different since a match type application can reduce to a regular type application:

class A {
  type F[X]
  type M[X] = X match {
    case Int => F[X]
    case _   => F[X]
  }

  def foo(x: M[_]): M[_] = x
}

Though my recollection is that allowing unrestricted wildcard applications is not by itself unsound, the problems come from trying to decide which types are subtype of that type and getting it wrong, but if we're conservative and accept that M[_] has no known subtype, then I believe we're OK.

@odersky
Copy link
Contributor Author

odersky commented Mar 22, 2021

@smarter Yes, in your example M[_] would not reduce to F[_].

@odersky odersky added this to the 3.0.0-RC2 milestone Mar 22, 2021
@odersky odersky requested a review from smarter March 22, 2021 21:54
@smarter smarter merged commit 46eb23e into scala:master Mar 23, 2021
@smarter smarter deleted the fix-9999 branch March 23, 2021 18:07
odersky pushed a commit to dotty-staging/dotty that referenced this pull request Mar 24, 2021
Don't flag match type aliases as unreducible
@Kordyjan Kordyjan modified the milestones: 3.0.0-RC2, 3.0.0 Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants