-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Confusing message when prefix is being shadowed in metadata #34545
Comments
The grammar for annotations allows If the program works without the prefix, then it can't be because the declaration isn't constant. I see no error when writing something like that myself, like: @c.override
import "dart:core" as c;
@c.override
void main(@c.override c.List<c.String> args) {
c.print("Hello world");
} Can you describe how you run the program, and what the declaration of |
I don't think I've tried doing deferred imports yet. The difference from what I see in your example is you wrote The fruit_providers file solely consisted of I'll email you a link to the build logs. |
My annotation on the import statement has no meaning, it was just to demonstrate that it was also valid there (and core's I've looked at the error message. The text shown
comes from the front-end parser (fasta), so I'll loop in some people who knows about that. @askeksa-google, @peter-ahe-google |
This is not a parser problem. I don't know why @lrhn mentions the parser. This message is from |
@kriswuollett I'm having a hard time reproducing this. Is it possible that |
Yes, most likely the module looked like this and there was unexpected name shadowing in the test script: // providers_test.dart:
import 'package:fruit/fruit_provider.dart';
import 'package:fruit/fruit_providers.dart' as providers;
// ...
@module
class TestProvidersModule {
@provide
@singleton
BuiltMap<String, Provider> providers(
@providers.apples Provider appleProvider,
@providers.oranges Provider orangeProvider) =>
BuiltMap.of(Map.fromEntries([
appleProvider, orangeProvider
].map((provider) => MapEntry(provider.name, provider))));
}
class TestFruitApp {
@provide
TestFruitApp(this.providers);
final BuiltMap<String, Provider> providers;
}
// ... Unfortunately I was not able to find the exact snapshot of code and build log I tested since I believe I just saw that error in IntelliJ's Dart Analysis window and then just moved on after refactoring the code to use a different technique. I'd be satisfied if some sort of name shadowing created the situation. Feel free to close this issue. It is probably easier to just change the import alias name, than try to see if there is a way to specify the name scope of the alias, if there is such a way. |
Thank you. I'll keep this bug open to remind us that we need to improve the error message when a prefix is being shadowed. The error messages produced in this situation are rather obscure. |
I'd like to import a file of inject Qualifiers using an import alias to keep the names scoped. For example:
But I get the error
error: Annotation must be either a const variable reference or const constructor invocation. (invalid_annotation at [dart] something.dart:123).
.If I remove the import alias it works fine. Is this a bug or a feature request?
Ideally I'd be using https://github.com/google/guice/wiki/Multibindings instead.
The text was updated successfully, but these errors were encountered: