Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Don't throw ClassCastException on certain compile errors. #258
Handle the failure of compilation better, so we don't find out because of a ClassCastException on a TypeElement.
This can happen when the element fails compilation in certain ways (say, missing symbols from using the wrong android SDK version, etc.). The compiler hands the Processor a bum AST which seems to put
This change simply validates the structure (and the implicit assumption of the cast) before performing the cast, so an error is trapped and reported, not thrown within the compilation job.
I haven't been able to replicate this in a simple consistent test, sadly, or I would include it here, but this code, in the real error inside google, resulted in the correct error being obvious. If nothing else, we should never be in a position where we throw out of a compilation/processing job, as that shuts down error reporting.
An LGTM from me means, "address the comments in the obvious way, then merge it yourself."
Anything else puts an unreasonably high cost on fixing spelling mistakes and other nitpicky things, in which we all delight in pointing out.
(If I didn't trust you, you wouldn't have commit privileges!)