Skip to content

Fix bug in erasedLub leading to incorrect signatures #2070

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 1 commit into from
Mar 9, 2017

Conversation

smarter
Copy link
Member

@smarter smarter commented Mar 8, 2017

Before this commit, the added testcase failed in a strange way:

14 |  def bla(foo: Foo) = orElse2(identity).apply(foo)
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |value of type <nonsensical><notype></nonsensical> does not take parameters

This happened because the TermRef for the apply method had an incorrect
signature (with a result type of Object instead of Foo), therefore its underlying type was NoType.

According to the documentation of erasedLub, the erasure should be:

a common superclass or trait S of the argument classes, with the
following two properties:

  • S is minimal: no other common superclass or trait derives from S]
  • S is last : in the linearization of the first argument type tp1
    there are no minimal common superclasses or traits that
    come after S.
    (the reason to pick last is that we prefer classes over traits that way).

I'm not convinced that the implementation satisfies either of these two
properties, but this commit at least makes S closer to being minimal by
making sure that it does not derive from the last seen best candidate never derives from it.

@smarter smarter requested a review from odersky March 8, 2017 21:55
Before this commit, the added testcase failed in a strange way:

14 |  def bla(foo: Foo) = orElse2(identity).apply(foo)
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |value of type <nonsensical><notype></nonsensical> does not take parameters

This happened because the TermRef for the apply method had an incorrect
signature, therefore its underlying type was NoType.

According to the documentation of `erasedLub`, the erasure should be:
  "a common superclass or trait S of the argument classes, with the
    following two properties:
      S is minimal: no other common superclass or trait derives from S]
      S is last   : in the linearization of the first argument type `tp1`
                    there are no minimal common superclasses or traits that
                    come after S.
  (the reason to pick last is that we prefer classes over traits that way)."

I'm not convinced that the implementation satisfies either of these two
properties, but this commit at least makes S closer to being minimal by
making sure that the last best candidate never derives from it.
@odersky
Copy link
Contributor

odersky commented Mar 9, 2017

The change LGTM. In the comment leading up to it, there's a stray ]. Also, we should change lub to erased lub in that comment for clarity.

@odersky
Copy link
Contributor

odersky commented Mar 9, 2017

I'll merge and piggyback the comment on some future PR.

@odersky odersky merged commit e28d8ee into scala:master Mar 9, 2017
@smarter
Copy link
Member Author

smarter commented Mar 9, 2017 via email

smarter added a commit to dotty-staging/dotty that referenced this pull request Mar 12, 2017
This wasn't done before because dotty could not compile dottydoc, this
got fixed by PRs scala#2070 and scala#2076.
smarter added a commit to dotty-staging/dotty that referenced this pull request Mar 12, 2017
This wasn't done before because dotty could not compile dottydoc, this
got fixed by PRs scala#2070 and scala#2076.
smarter added a commit to dotty-staging/dotty that referenced this pull request Mar 13, 2017
This wasn't done before because dotty could not compile dottydoc, this
got fixed by PRs scala#2070 and scala#2076.
smarter added a commit to dotty-staging/dotty that referenced this pull request Mar 13, 2017
This wasn't done before because dotty could not compile dottydoc, this
got fixed by PRs scala#2070 and scala#2076, and the previous commit fixed a
miscompilation issue.
smarter added a commit to dotty-staging/dotty that referenced this pull request Mar 14, 2017
This wasn't done before because dotty could not compile dottydoc, this
got fixed by PRs scala#2070 and scala#2076, and the previous commit fixed a
miscompilation issue.
smarter added a commit to dotty-staging/dotty that referenced this pull request Mar 15, 2017
This wasn't done before because dotty could not compile dottydoc, this
got fixed by PRs scala#2070 and scala#2076, and the previous commit fixed a
miscompilation issue.
smarter added a commit to dotty-staging/dotty that referenced this pull request Mar 15, 2017
This wasn't done before because dotty could not compile dottydoc, this
got fixed by PRs scala#2070 and scala#2076, and the previous commit fixed a
miscompilation issue.
smarter added a commit to dotty-staging/dotty that referenced this pull request Mar 15, 2017
This wasn't done before because dotty could not compile dottydoc, this
got fixed by PRs scala#2070 and scala#2076, and the previous commit fixed a
miscompilation issue.
smarter added a commit to dotty-staging/dotty that referenced this pull request Mar 16, 2017
This wasn't done before because dotty could not compile dottydoc, this
got fixed by PRs scala#2070 and scala#2076, and the previous commit fixed a
miscompilation issue.
@allanrenucci allanrenucci deleted the fix/erasedLub branch December 14, 2017 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants