Don't throw ClassCastException on certain compile errors.

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 `@Provides` annotations structurally on the class (normally quite impossible).  The resulting error is obscure and doesn't show which class the problem is occurring on.  

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.