bug: JDTTreeBuilderQuery.searchTypeBinding can fail to find nested types
- Dominant language
- Java
- Stars
- 2k
- Forks
- 392
- Avg merge
- 11h 24m
- Merged PRs (30d)
- 36
Description
I stumbled upon this when working on #3707
In `JDTTreeBuilderQuery.searchTypeBinding`, there's this small part where it searches nested types of a type declaration.
https://github.com/INRIA/spoon/blob/f3d1677b725f88078812a4d61c5d8eb252a339da/src/main/java/spoon/support/compiler/jdt/JDTTreeBuilderQuery.java#L81-L87
The expression `qualifiedName.equals(CharOperation.toString(memberType.binding.compoundName))` is the problem, because `qualifiedName` is a dot-separated qualified name, while `CharOperation.toString(memberType.binding.compoundName)` will delimit nested types with `$`. For example, with this declaration:
```java
package pkg;
class Outer {
class Inner {}
}
```
`qualifiedName` will be `pkg.Outer.Inner`, whereas `CharOperation.toString(memberType.binding.compoundName)` will be `pkg.Outer$Inner`. The return statement in the middle is not covered by the test suite (see [the latest coverage report](https://coveralls.io/jobs/71160098/source_files/3781023179#L84)), so I suspect that it simply can't be hit.
This isn't hard to fix, I think I can get around to it sometime this week.
Contributor guide
Assessment
This issue has not been assessed yet.