Skip to content

Fix #9058: disable failing performance optimization during implicits lookup #9060

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
wants to merge 1 commit into from

Conversation

anatoliykmetyuk
Copy link
Contributor

@anatoliykmetyuk anatoliykmetyuk commented May 27, 2020

No description provided.

It appears to break the `prefer` function's contract
as a comparator function.
@anatoliykmetyuk anatoliykmetyuk changed the title Fix #9058: the sorting function's if-statements for implicit lookup are 'total' Fix #9058: disable failing performance optimization during implicits lookup May 27, 2020
@anatoliykmetyuk anatoliykmetyuk marked this pull request as ready for review May 27, 2020 19:28
@anatoliykmetyuk
Copy link
Contributor Author

test performance please

@dottybot
Copy link
Member

performance test scheduled: 1 job(s) in queue, 0 running.

@anatoliykmetyuk anatoliykmetyuk linked an issue May 27, 2020 that may be closed by this pull request
@odersky
Copy link
Contributor

odersky commented May 27, 2020

Can you explain why the disabled lines violate the transitivity contract?

@odersky
Copy link
Contributor

odersky commented May 27, 2020

Oh, I think I see it:

object A extends B
class C extends A

Then C <: A$ and A$ <: B but we do not have C <: B.

But maybe we should just drop these two lines in compareOwner instead:

    else if (sym2.is(Module)) compareOwner(sym1, sym2.companionClass)
    else if (sym1.is(Module)) compareOwner(sym1.companionClass, sym2)

Can you try that?

@odersky
Copy link
Contributor

odersky commented May 27, 2020

In fact, my previous suggestion fails tastyBootstrap. But the following version should work:

  def compareOwner(sym1: Symbol, sym2: Symbol)(using Context): Int =
    if sym1 == sym2 then 0
    else if sym1.isSubClass(sym2) then 1
    else if sym2.isSubClass(sym1) then -1
    else if sym1.is(Module) && sym2.is(Module) then
      compareOwner(sym1.companionClass, sym2.companionClass)
    else 0

EDIT: It does not. Here's a counter example:

A <: B, B$ <: C
then
A$ <: B$, B$ <: C
yet not
A$ <: C

@dottybot
Copy link
Member

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/9060/ to see the changes.

Benchmarks is based on merging with master (2116281)

@odersky
Copy link
Contributor

odersky commented May 28, 2020

In fact there was also somehthing wrong with prefer. Function arity should be compared before owner subclasses.

@anatoliykmetyuk
Copy link
Contributor Author

Superseded by #9065.

@anatoliykmetyuk anatoliykmetyuk deleted the i9058 branch May 28, 2020 11:28
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.

Scalaz broken in community build
4 participants