walkmod / walkmod-dead-code-cleaner-plugin

Walkmod plugin to remove unused variables, methods and fields
2 stars 2 forks source link

Private methods and members used in lambdas are incorrectly identified as deadcode #4

Closed pleschev closed 6 years ago

pleschev commented 6 years ago

I'm not sure if this is a problem with the dead code cleaner plugin, or an issue that needs to be raised in https://github.com/rpau/javalang/issues

pleschev commented 6 years ago

I have raised PR#5 which contains a testcase that recreates the problem. My understanding is that MethodDeclaration.usages should contain references to method usages when they are used in lambdas, however, they are currently not being populated. I suspect the fix will require a change in rpau/javalang however, I'm not 100% sure, and would love some guidance on how to fix this problem

rpau commented 6 years ago

Thanks a lot @pleschev for reporting this :)

The repository that performs that computation(the symbol resolution and the dependencies) is this one: https://github.com/rpau/javalang-compiler

Indeed, I recommend you to check this file: https://github.com/rpau/javalang-compiler/blob/master/src/test/java/org/walkmod/javalang/compiler/SymbolVisitorAdapterTest.java

It is a project, that IMO is very clean and well designed but requires some background of compilers. I encourage you to send a patch, but let me know if you need any help/guiadance by creating a ticket in that repo.

pleschev commented 6 years ago

Thanks for the feedback & guidance. I've raised https://github.com/rpau/javalang-compiler/issues/76

rpau commented 6 years ago

Fixed here: https://github.com/rpau/javalang-compiler/pull/78