Skip to content
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

Fix unstable ordering of methods #1394

Merged
merged 2 commits into from
Aug 28, 2020
Merged

Fix unstable ordering of methods #1394

merged 2 commits into from
Aug 28, 2020

Conversation

kamildoleglo
Copy link
Contributor

Closes #1333
This PR also fixes a bug in SearchbarDataInstaller which had a race condition when used asynchronously from HtmlRenderer

@kamildoleglo kamildoleglo added this to the 1.4.0 milestone Aug 27, 2020
@kamildoleglo kamildoleglo marked this pull request as draft August 27, 2020 13:15
@kamildoleglo kamildoleglo marked this pull request as ready for review August 27, 2020 13:23
@@ -129,7 +130,7 @@ open class DefaultPageCreator(
divergentBlock("Types", types, ContentKind.Classlikes, extra = mainExtra + SimpleAttr.header("Types"))
divergentBlock(
"Functions",
s.functions,
s.functions.sort(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question:
Would we maybe benefit from (whoever is containing this functions) already having the ordered the same way?
Maybe we are using the functions somewhere else and have unexpected unintuitive order somewhere? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree and that was my first idea, but then after a discussion with @Kordyjan we decided to do it this way, as the presentation side is responsible for the correct displaying of declarations (and TBH it's faster this way as we don't have to modify the data structure)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats okay ☺️ Good argument!

@@ -174,6 +175,9 @@ open class DefaultPageCreator(
}
}

private fun Collection<DFunction>.sort() =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extension might maybe be better on Iterable than Collection?
Would it make sense to let DFunction impelement Comaprable or is this order to specific to the current use case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extension might maybe be better on Iterable than Collection?

Sure, changed 👍

Would it make sense to let DFunction impelement Comaprable or is this order to specific to the current use case?

We can do that, I have two issues with this approach though:

  1. It would be kind of inconsistent with other Documentables that don't implement Comparable
  2. The order here is introduced only for sensible presentation (eg. we prefer methods alphabetically with less arguments) and not for some sort of actual order. When implementing Comparable I feel like one can assume that one method is bigger or smaller than other (as it would be then possible to do fun1 >= fun2) and it may lead to some wrong impressions based on different assumptions what bigger means.

Maybe we should rename sort to something like orderLexicographically() ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good arguments presented ☺️
I would be fine with calling it sort. Will merge this if you are either ☺️

@sellmair sellmair added the bug label Aug 28, 2020
@sellmair
Copy link
Member

Cherry picked into 1.4.0 🍒

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unstable sort order for overloaded member functions
3 participants