eclipse-aspectj / aspectj

Other
303 stars 86 forks source link

Joinpoint matching problems related to array types #210

Closed kriegaex closed 1 year ago

kriegaex commented 1 year ago

Fixes https://github.com/eclipse/org.aspectj/issues/24.

For now, this PR is just a draft, because it only contains a set of 4 regression tests, only one of which passes. The PR is meant to produce CI build results, making it easier for @aclement to collaborate. Andy, maybe you know how to quickly fix the problems at hand if you can just check out the feature branch, run the tests and focus on the bugfix. I did the initial leg work for you already.

kriegaex commented 1 year ago

Hm, after my changes now * does not match array types anymore, because e.g. *[] matches 1-dimensional and *[][] 2-dimensional arrays. That is a regression which I did not consider while fixing the array type bugs. I guess, my PR needs a little rework. Sorry for not running the unit tests locally, only the new integration tests.

kriegaex commented 1 year ago

The previous problem and a few others I detected along the way have been fixed.

While testing array type wildcard expressions, I noticed that we are missing syntax for explicitly matching non-array types. While for exact types, FooBar does not match FooBar[] or FooBar[][] types, in the wildcard case Foo* matches arrays, too. In order to exclude arrays, we have to do something like execution(Foo* *(..)) && !execution(Foo*[] *(..)) && !execution(Foo*[][] *(..)), because AspectJ is lacking a syntax such as Foo*![] or Foo*[0]. In order to add that, we would have to extend the grammar and the parser. Class WildTypePattern would also need a member to store the array exclusion or add special semantics to something like getDimension() returning -1 or so. For now, I chose not to do that, but it is something to keep in mind. WDYT, @aclement?