Skip to content

Conversation

@Arthur-Milchior
Copy link
Member

@Arthur-Milchior Arthur-Milchior commented Nov 4, 2024

This PR (quite simplified compared to first version), replace some else -> by an exhaustive constant list. This will ensure that if more enum are added, we won't forget to consider all enums

@david-allison
Copy link
Member

david-allison commented Nov 12, 2024

Could you split this into a few smaller PRs (~2/300 lines each)? This isn't going to be easy to review otherwise, especially as it's low priority.

The first commit in the series uses single variable names for a class (.B implies boolean), which doesn't feel at all intuitive. I suspect the rest is mergeable, but it's a huge time commitment in this state, and attracts conflicts


IntFlags existed because in the early days, Android was extremely memory constrained, and Int used less memory than enum. A very quick Google returned: https://medium.com/trade-me/android-then-and-now-intro-intdef-enums-bca22d5cca56, but you'll easily find better articles.

I believe it was an AOSP standard for many years.

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Nov 12, 2024
@Arthur-Milchior
Copy link
Member Author

@david-allison done

@david-allison
Copy link
Member

Tests fail on this one

When `when` is used on an enum, the `else ->` can always be
transformed into a complete enumeration of the enum's entries.

This ensure that each time a new entry is added, there is a warning
and the developer must decide whether or not a change is needed. While
the `else` may hide some required change.

So, for the sake of future developement, I removed `else ->` when it
makes sense.

I should note that I kept some `else ->` when the `when` consider only
a very small part of all possible enum value, in order to reduce the
size of the code.
@github-actions
Copy link
Contributor

Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

@github-actions github-actions bot added the Stale label Nov 28, 2024
@github-actions github-actions bot closed this Dec 5, 2024
@Arthur-Milchior Arthur-Milchior deleted the else branch December 6, 2024 23:28
@Arthur-Milchior Arthur-Milchior restored the else branch December 6, 2024 23:30
@Arthur-Milchior Arthur-Milchior removed Needs Author Reply Waiting for a reply from the original author Has Conflicts labels Dec 6, 2024
@Arthur-Milchior
Copy link
Member Author

Actually needed to be closed, everything was merged in separate PR

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.

2 participants