Skip to content

Issue with GADTs tasty types #2944

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

Closed
nicolasstucki opened this issue Aug 2, 2017 · 6 comments
Closed

Issue with GADTs tasty types #2944

nicolasstucki opened this issue Aug 2, 2017 · 6 comments

Comments

@nicolasstucki
Copy link
Contributor

trait Map2[K] {
  def get(k: K) = null
  def foo = {
    this match {
      case that: Map2[b] => that.get(3.asInstanceOf[b])
      case that: Map2[c] => that.get(4.asInstanceOf[K])
      case _ => get(5.asInstanceOf[K])
    }
  }
}

gets wrong types for binding in 3.asInstanceOf[b] and 4.asInstanceOf[K] involving b and c.

The full tasty pretty printed is here.

@nicolasstucki
Copy link
Contributor Author

In the first case the binding of b in missing the inferred upper bound on K.

                          Bind(UTF8: b)
                           type
                            SHARED(15)
                              TypeBounds
                               low:
                                TypeRef(UTF8: Nothing)
                                 qualType:
                                  TermRefPKG: UTF8: scala
                               high:
                                TypeRef(UTF8: Any)
                                 qualType:
                                  SHARED(19)
                                    TermRefPKG: UTF8: scala

@nicolasstucki
Copy link
Contributor Author

The second case apply the binding instead of the type.

TypeApply
                            fun:
                              Select(Signed orig: [UTF8: asInstanceOf]() :[Qualified [Qualified [UTF8: java].[UTF8: lang]].[UTF8: Object]])
                               qual:
                                ...
                            args:
                              SHARED(154)
                                Bind(UTF8: c)
                                 type
                                  SHARED(15)
                                    TypeBounds
                                     low:
                                      TypeRef(UTF8: Nothing)
                                       qualType:
                                        TermRefPKG: UTF8: scala
                                     high:
                                      TypeRef(UTF8: Any)
                                       qualType:
                                        SHARED(19)
                                          TermRefPKG: UTF8: scala

@nicolasstucki
Copy link
Contributor Author

These trees fail Ycheck after phase classOf if loaded.

This was discovered in #2910 and can be reproduced with the tests/link/on-custom-lib/map2.scala by uncommenting the code.

@nicolasstucki
Copy link
Contributor Author

This code in present in strawman.collection.Map.equals.

@DarkDimius DarkDimius self-assigned this Aug 4, 2017
@DarkDimius
Copy link
Contributor

Taking over this blocker.

DarkDimius added a commit to dotty-staging/dotty that referenced this issue Aug 4, 2017
This allows all other parts of pipeline to be less aware of existence
of the GADT bounds.

In particular, it makes us pickle them as normal type bounds.
DarkDimius added a commit to dotty-staging/dotty that referenced this issue Aug 4, 2017
@DarkDimius
Copy link
Contributor

Fix ready. It was easy.

nicolasstucki pushed a commit to dotty-staging/dotty that referenced this issue Aug 4, 2017
This allows all other parts of pipeline to be less aware of existence
of the GADT bounds.

In particular, it makes us pickle them as normal type bounds.
nicolasstucki pushed a commit to dotty-staging/dotty that referenced this issue Sep 21, 2017
nicolasstucki added a commit that referenced this issue Sep 21, 2017
Fix #2944: propagate information from GADT bounds to normal info.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants