Skip to content

Commit

Permalink
NotTypePattern: Fix matching problem for negated type patterns
Browse files Browse the repository at this point in the history
The implementation for boolean matchesArray(UnresolvedType type) was
buggy.

'!String' should match anything but String, no matter if it is
an array or not, e.g. int, void, int[], String[], String[][].

'!String[]' should match anything but String[], no matter if it is
an array or not, e.g. int, void, int[], String, String[][].

Fixes #257.

Signed-off-by: Alexander Kriegisch <[email protected]>
  • Loading branch information
kriegaex committed Aug 23, 2023
1 parent 4004d0d commit 29b84c2
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType)

@Override
protected boolean matchesArray(UnresolvedType type) {
return !negatedPattern.matchesArray(type);
// '!String' should match anything but String, no matter if it is an array or not,
// e.g. int, void, int[], String[], String[][].
//
// '!String[]' should match anything but String[], no matter if it is an array or not,
// e.g. int, void, int[], String, String[][].
return true;
}

@Override
Expand Down

0 comments on commit 29b84c2

Please sign in to comment.