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

Should we have an error or warning for a static method on an unnamed extension? #617

Closed
natebosch opened this issue Oct 9, 2019 · 2 comments
Labels
extension-methods question Further information is requested

Comments

@natebosch
Copy link
Member

extension on String {
  static String cannotCall() => '';
}

As far as I can tell there is no way to invoke cannotCall given this definition, so it's not useful to define it. Should we make this an error or warning?

@bwilkerson
Copy link
Member

It can be invoked from within the extension, so I expect it won't be an error.

It's a TODO for the analyzer to detect it as dead code if it isn't being invoked.

@lrhn
Copy link
Member

lrhn commented Oct 22, 2019

Agree. There is nothing inherently wrong with having local static helper functions in scope and used by the extension members.

It's dead code, like any other static on a private class, if it's not actually used by the containing library, and the analyzer should be able to recognize that normally.

@lrhn lrhn closed this as completed Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-methods question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants