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

Some enum #17435

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Some enum #17435

wants to merge 2 commits into from

Conversation

Arthur-Milchior
Copy link
Member

Those commits add some enum for the sake of code clarity

That allows to remove a else -> and improve typing.
Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

Note: both of these classes are planned to be deleted.

Signal is fine. Good change

I don't like Caller from an architecture POV, but I don't feel strongly here.

I do want to stop using implicit enum ordinals, and that's what I'll request changes on: that makes the order of the enums a source of bugs.

AnkiDroid/src/main/java/com/ichi2/anki/NoteEditor.kt Outdated Show resolved Hide resolved
ADD_IMAGE,
INSTANT_NOTE_EDITOR;
companion object {
fun Int.toCaller() = Caller.entries[this]
Copy link
Member

Choose a reason for hiding this comment

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

This is a recipe for disaster, keep the enum ints explicit

This now throws on an unexpected value

Copy link
Member Author

Choose a reason for hiding this comment

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

If this were expected to survive, I'd prefer to see an acra report on unexpected value. Because that's unexpected, and I'd prefer to know this occurs. Because that means that we probably don't do what we expect to do when the collection is loaded

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Author Reply Waiting for a reply from the original author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants