Generated code has "Parameter is hiding a field" warnings all over
See original GitHub issueThe below is the generated code for one of my components:
public CoreModule_ProvideUpdateCheckerFactory(
Provider<Settings> aSettingsProvider,
Provider<UpdateChecker.UpdateCallback> aUpdateCallbackProvider,
Provider<String> aVersionProvider) {
assert aSettingsProvider != null;
this.aSettingsProvider = aSettingsProvider;
assert aUpdateCallbackProvider != null;
this.aUpdateCallbackProvider = aUpdateCallbackProvider;
assert aVersionProvider != null;
this.aVersionProvider = aVersionProvider;
}
This occurs for just about all generated code.
This code causes a warning for each of the parameters to the tune of:
The parameter SettingsProvider is hiding a field from type CoreModule_ProvideUpdateCheckerFactory
This is caused by the formal parameter having the same name as the field in the class. The code works correctly thanks to qualification using this.
. Could the code generation be change to set a prefix or suffix or something on the formal arguments to avoid this warning?
Warning for variable shadowing is default in Eclipse AFAICT.
Dagger version 2.10, Java 8.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9
Top Results From Across the Web
java - Troubleshooting "The type parameter T is hiding the ...
The warning appears at 'T' in 'A' and reads: "The type parameter T is hiding the type T". The weird part is that...
Read more >Compiler warning "is hiding a field" given for static inner class
The language spec tolerates field hiding. As a courtesy we will warn the user if the optional diagnosis for field hiding is enabled....
Read more >Warning Options (Using the GNU Compiler Collection (GCC))
Warnings are diagnostic messages that report constructions that are not inherently erroneous but that are risky or suggest there may have been an...
Read more >C# preprocessor directives - Microsoft Learn
Learn the different C# preprocessor directives that control conditional compilation, warnings, nullable analysis, and more.
Read more >Predefined Annotation Types - Java™ Tutorials
The Java Tutorials have been written for JDK 8. ... The compiler generates a warning whenever a program uses a method, class, or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think your best bet is to just deal with this on the eclipse end. See this Stack Overflow question and this bug. Apparently Eclipse runs afoul of quite a few code generators…
We hold the generated code to exactly that standard, but only for
javac
. Eclipse adds a whole bunch of other non-standard checks that change from release to release. We can’t possibly track every new check added by every IDE or static analysis tool, so we drew the line at the standard compiler. I don’t think that’s going to change any time soon, especially given that this is a style check and not a correctness issue.