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

Sealed base type for Kord events #904

Open
gdude2002 opened this issue Jan 6, 2024 · 2 comments
Open

Sealed base type for Kord events #904

gdude2002 opened this issue Jan 6, 2024 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@gdude2002
Copy link
Contributor

Currently, Kord events all extend the Event interface, which is open. This is good - it means that frameworks can combine their events with Kord's in their event handling systems trivially.

However, this also creates a problem - when using a when for type checking event objects, the compiler/IDE will be unable to generate an exhaustive list of conditionals. In the case of KordEx, which has functions like this to extract data from Kord events, this means it's very difficult for me to know about changes to Kord's event line up.

To fix this, I propose adding a sealed interface inherited by all Kord event types - perhaps named KordEvent. While this would not solve the problem of generic entity extraction, it would allow framework developers to quickly generate a full list of Kord event types when working with these when blocks.

@lukellmann
Copy link
Member

Sounds reasonable to me 👍

PR welcome :)

@lukellmann lukellmann added help wanted Extra attention is needed good first issue Good for newcomers labels Jan 7, 2024
@lukellmann
Copy link
Member

I just noticed that this won't be that easy. Right now, Kotlin forces all direct inheritors of a sealed type to be in the same package as the sealed type. However, Kord's events are already placed into different packages.

Also see https://youtrack.jetbrains.com/issue/KT-44895

@lukellmann lukellmann removed the good first issue Good for newcomers label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants