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 class detection is buggy when parameters are overriden #210

Open
sksamuel opened this issue May 14, 2021 · 7 comments
Open

Sealed class detection is buggy when parameters are overriden #210

sksamuel opened this issue May 14, 2021 · 7 comments
Labels

Comments

@sksamuel
Copy link
Owner

sksamuel commented May 14, 2021

sealed class Sealed
data class One(val a: String) : Sealed()
data class Two(val a: String, val b: Int) : Sealed()

Will always pick the first one.

@sksamuel sksamuel changed the title Sealed class detection is buggy Sealed class detection is buggy when parameters of one class are a subset of another May 14, 2021
@sksamuel
Copy link
Owner Author

@VapidLinus

@sksamuel sksamuel changed the title Sealed class detection is buggy when parameters of one class are a subset of another Sealed class detection is buggy when parameters are overriden May 14, 2021
@sksamuel
Copy link
Owner Author

sksamuel commented May 14, 2021

So delving in deeper, when you override a value, you're not overriding the whole object, but overriding that specific value, which means there's ambiguity over which to pick.

So in your original example:

config.toml

total-miss-count = 12
blank-emote = { id = "139498586236518441", guild = "153217084425764864" }

default-config.toml

total-miss-count = 7
blank-emote = { name = ":black_small_square:" }

Merged result

total-miss-count = 12
blank-emote = { name = ":black_small_square:", id = "139498586236518441", guild = "153217084425764864" }

So now which subtype to pick ?

@sksamuel
Copy link
Owner Author

I guess for TOML only, we could introduce a flag that allows you to specify that an inline table completely overrides?

@VapidLinus
Copy link

Maybe it could be an annotation on the sealed class that "flags" it for overriding the table completely?

That way it would be backwards compatiable and the old behavior can still be achieved when wanted.

@sksamuel
Copy link
Owner Author

That would be nice from a user point of view. The problem is hoplite generates the entire tree of values before then applying it to the config classes.

That idea might work if the node's where lazy which perhaps we could do in the 2.0 update that I'm planning.

@stale
Copy link

stale bot commented Jul 13, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jul 13, 2021
@sksamuel sksamuel added pinned and removed wontfix This will not be worked on labels Jul 13, 2021
@sksamuel
Copy link
Owner Author

sksamuel commented Aug 5, 2022

#329

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

No branches or pull requests

2 participants