-
Notifications
You must be signed in to change notification settings - Fork 214
Can we allow mixin on <SealedClass>
?
#3215
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
Comments
To my horror, I have just realized we allow you to implement mixin types. That would mean this mixin does introduce a new real subtype of the sealed class, so it isn't safe. Do we really want you to be able to implement a mixin type? Is that something people do? If we blocked that, then would we be able to allow this? |
This was part of one of my designs along the way. Then we can ensure that no instance of a subtype of a sealed class is not also an instance of one of the known direct subclasses, because the only way to create an instance implementering the mixin type, is to apply it to a real subclass of the on-type. And if you don't want people implementing your mixin type, make it |
Yeah, I was discussing this at lunch with others and the idea of using |
Would it be reasonable to do this? Essentially say that you can't violate the normal rules (even in your own library) for a |
I already specified it, and fully believe it should be sound and safe. We would have to prevent everyone from implementing the mixin, in the same library or other libraries, even if the mixin is declared in a non-feature library. That's extra special, because they cannot write So it does get complicated. |
Ok, the juice might not be worth the squeeze then in this case. It does feel like a workaround, I was probably trying to be a bit too fancy. What I really want here is intersection types anyways :). |
Uh oh!
There was an error while loading. Please reload this page.
There might be a better way to do this, if so please let me know :).
Consider a sealed class hierarchy, with private *Impl classes, and the *Impl classes also implement another shared interface.
Internally to my code, I want to only deal in the *Impl classes, but I can't declare a type which enforces something to be both the sealed class plus the additional private interface. I end up having to choose one or the other.
my_public_library.dart
my_private_library.dart
internal_usage.dart
The text was updated successfully, but these errors were encountered: