-
Notifications
You must be signed in to change notification settings - Fork 8
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
Figure out how we will handle the fact that adding an extension method can be breaking #620
Comments
Adding an extension method is like adding a top-level name - it can conflict with other declarations with the same name in the same scope. We don't generally disallow adding top-level members, and the recommended solution for conflicts, which you discover when you do a Doing a I think the strategy for conflicting extensions should be the same, which means not doing anything in particular, and patching up conflicts when they occur. The one additional crinkle with extensions is that hiding the extension will hide all its members. The counter-design to that problem is to put each individual extension method in its own extension declaration. See #613. Another alternative is to allow hiding individual extension members. See dart-lang/language#1627. For now, you have to either |
Collecting examples of hitting this problem when rolling this package internally:
|
It does seem clear at this point that these conflicts are a much more common occurrence than when adding new top level symbols, and probably deserve some special treatment and/or pattern for how we address them? |
I think we should try publishing and see what kind of noise it makes in the ecosystem, then use what we learn to make decisions about potential conflicts in the future. |
The safest approach appears to be to have an extension declaration per extension method, because then you can hide individual extensions without losing any other extension method. There is no way to avoid conflicts, other than not adding new extensions at all, which is not viable. It's just highly annoying to have to have to split a group of related extensions into separate and individually named extensions, and it's not something I'd expect from other package authors. |
dart-archive/collection#196 introduced an extension method which conflicted with the same name defined in another library in at least one internal usage. We can handle the conflict internally, but on pub it may not be as easy.
cc @lrhn
The text was updated successfully, but these errors were encountered: