dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.24k stars 1.58k forks source link

[Analyzer] Please update `deferred_import_of_extension` error message #56716

Open sgrekhov opened 2 months ago

sgrekhov commented 2 months ago

According to extension methods specification

It is a compile-time error if a deferred import declaration imports a library with an extension declaration in its export scope, unless all such extensions are hidden by a hide combinator with the extension's name, or a show combinator without the extension's name, on the deferred import.

If this error occurs analyzer produces the following error message

Imports of deferred libraries must hide all
          extensions. Try adding either a show combinator listing the names you need to    
          reference or a hide combinator listing all of the extensions. •
          deferred_import_of_extension

The sentence "...must hide all extensions..." was fine before introducing of extension types. Now it sounds as if extension types also should be hidden but it isn't so. Please change the message to "...must hide all extension methods..." or similar.

eernstg commented 2 months ago

Oh, I have to say that I had that problem many times!

If you say 'extension types' then there's no doubt, but if you say 'extensions' then it's never obvious whether you'd also need to say '(that is, extension declarations, not extension type declarations)'.

The language specification uses 'extensions'. The feature specification (which is not normative at this time, it's kept around in order to document the background and history of this feature) uses 'static extension methods'. We have an ongoing discussion about adding a new feature that might get the syntax static extension .... Of course, all kinds of extensions have methods, they are all resolved statically, and (for good measure) they all support static method declarations. :grinning:

It would be nice if we could decide on a specific phrase to denote this particular feature (provided by extension declarations), but I'm afraid we don't have a good phrase to standardize on today.

As an aside, it isn't the library which is deferred, it's the import, so the error message should probably say something like 'Deferred library imports' rather than 'Imports of deferred libraries'.

Perhaps this could work?: "Deferred library imports must hide all extension declarations. ..."