[antlr-interest] Removing unnecessary casts

Andreas Stefik stefika at gmail.com
Sun May 23 13:21:41 PDT 2010


Hi folks,

I'm going through my compiler finally removing some warnings and other
minor issues, as we bug fix and generally get ready for release. I was
wondering, when ANTLR generates code (Java target), it generates a
great of things "like" the following:

Object IF50_tree=null;

IF50_tree = (Object)adaptor.create(IF50);


Now, since IF50_tree is defined as an object, the second statement's
cast to type Object is redundant, which then throws a warning in the
compiler output. Is there any way to turn off the duplicate cast,
thereby making ANTLR generate, instead of the above, the following:

IF50_tree = adaptor.create(IF50);

This would remove the warnings. It's not a big deal, but since ANTLR
generates approximately 100 of these warnings (all caused by the same
issue), it sometimes gets in the way me digging through and finding
real problems.

Thoughts?

Stefik


More information about the antlr-interest mailing list