-
Notifications
You must be signed in to change notification settings - Fork 57
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
Suppress "unused import" warning when only using an import reflectively #2
Comments
This looks more like a case where configurable imports are involved, such that one variant of the program will "use reflection" and the other one will not. The Reflectable transformer transforms a program that uses dart:mirrors (indirectly, behind a layer of wrappers with statically known types from package:reflectable/mirrors.dart) into a modified version of the program that uses a statically generated set of mirrors (such that there is no dependency on dart:mirrors). The client code will no longer have an "import 'package:reflectable/reflectable.dart';" anywhere, but it will appear to use reflection just as much as it did before the transformation. The difference is only that the pre-transform code relied (indirectly) on dart:mirrors, and the post-transform code does not. So, as far as I can see, you won't get into a situation where you have any unused imports as described. |
I can see where the transformed code may be able to avoid the unused import warning. But in pre-transform (source) code, where it counts most, the unused import will clearly still be there if there is an import used only reflectively. So there would need to be support for informing the analyzer that the import is being used reflectively. |
I'm not sure I understand what you mean. Both pre-transform and post-transform code would contain reflective constructs, or maybe both of them don't (but that's a pathological case, then there's no need to use Reflectable at all). So when would that import be unused? The Reflectable transformer does not remove "reflective code" during transformation, it redefines the meaning of such code, in order to eliminate the (indirect) dependency on dart:mirrors. This happens because classes such as InstanceMirror are implemented using dart:mirrors in pre-transform code, and they are statically generated (not depending on dart:mirrors) in the post-transform code. |
Similar to:
I want to be able to do something like:
to avoid an "unused import" warning, when I only use
package:reflected_upon/reflected_upon.dart
reflectively. Is/will that be possible?The text was updated successfully, but these errors were encountered: