If root
is a private field in your class that contains the add
method you posted, then, as you said, the line root = e;
should not be considered dead code by the Eclipse IDE.
The compiler should work fine ... it's just an IDE warning.
My guess would be that Eclipse does some sort of code walking (similar to Cyclomatic complexity tools) to determine code paths and find "dead code" and "unreachable code".
I would try refreshing, then doing a clean and build in the IDE. If that doesn't resolve it, Eclipse may just have a "false positive" on warning on dead code. Wouldn't be the first time ... I use both Eclipse and IntelliJ IDEA and have seen both IDEs incorrectly warn on code before. However, my code still compiles fine despite the IDE warning.