VariableTree.getNameExpression and TreeScanner

Werner Dietl wdietl at gmail.com
Thu May 23 00:27:45 PDT 2013


Jon, all,

in this changeset:

http://hg.openjdk.java.net/type-annotations/type-annotations/langtools/rev/529fb3ed5d2a

you modified TreeScanner.visitVariable to traverse the NameExpression
- which is used for the receiver parameter name.

I found it surprising that suddenly an extra "visitIdentifier" gets
called because of this.
The same does not happen for value parameter names - we never traverse
on the value of getName().

If I remove that traversal, test case
tools/javac/tree/SourceTreeScannerTest.java
starts failing, but everything else continues to work.

I can work around this extra invocation in the Checker Framework. But
as I found this surprising, I wanted to confirm that this is the
desired behavior.
Why is it desirable to traverse the receiver parameter name, which is
usually simply "this"?
Should other parameter names also be visited, for consistency?

cu, WMD.

--
http://www.google.com/profiles/wdietl


More information about the type-annotations-dev mailing list