Fix matching logic for complex pointcuts combined with || - #65
Merged
Conversation
Combined pointcuts delegated matching to each sub-pointcut regardless of the element's join point kind, so in an expression like 'execution(public **->data*(*)) || access(public **->$id*)' the KIND_METHOD execution clause could match a field named 'dataMap' purely by name pattern (and the access clause could match methods), producing false-positive line markers. Add the matching context from goaop/framework#274 as a kind gate: - New Set<KindFilter>.supports(element) extension maps Method/Field/ PhpClass elements to KIND_METHOD/KIND_PROPERTY/KIND_CLASS. - AndPointcut.isMatchesPointcut (shared by OrPointcut) now skips sub-pointcuts whose kind set does not support the element, which also stops class-kind TruePointcut branches (initialization()) from leaking every member through an OR. - SignaturePointcut.matches() now checks its own filterKind, consistent with AttributePointcut. - AttributePointcut reuses the shared helper instead of its private canMatchElement. Tests: new OrPointcutKindMatchingTest regression suite with real SignaturePointcuts mirroring the issue scenario, kind-gate tests for And/OrPointcut and SignaturePointcut, supports() coverage in KindFilterTest, and existing mocks tightened from bare PhpClassMember to Method so they pass the stricter gate realistically. Fixes #9 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015GwCyE8P8udW5VMJHY4qGk
Qodana for JVMIt seems all right 👌 No new problems were found according to the checks applied 💡 Qodana analysis was run in the pull request mode: only the changed files were checked View the detailed Qodana reportTo be able to view the detailed Qodana report, you can either:
To get - name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2026.1.3
with:
upload-result: trueContact Qodana teamContact us at qodana-support@jetbrains.com
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9
Problem
Combined pointcuts delegated matching to each sub-pointcut regardless of the element's join point kind. In an expression like
the
KIND_METHODexecution clause could match a field nameddataMappurely by name pattern (and the access clause could match methods namedid*), producing false-positive line markers.OrPointcut.getKind()is the union of the clause kinds andPointcutAdvisorgates only on that aggregate, so the wrong-kind element always reached the kind-blind clause. A related leak:... || initialization(Foo)compiles the initialization branch toTruePointcut(KIND_CLASS)whosematches()is alwaystrue, so every member of a matching class matched through that OR branch.Fix
Adds the matching context from goaop/framework#274 (the join-point kind) as a gate on sub-pointcut delegation:
Set<KindFilter>.supports(element)extension inKindFilter.ktmapsMethod/Field/PhpClasselements toKIND_METHOD/KIND_PROPERTY/KIND_CLASS.AndPointcut.isMatchesPointcut(shared byOrPointcutvia inheritance) now skips sub-pointcuts whose kind set does not support the element — this also fixes theinitialization()leak above.SignaturePointcut.matches()now checks its ownfilterKind, consistent with howAttributePointcutalready behaved.AttributePointcutreuses the shared helper instead of its privatecanMatchElement(behavior unchanged).Not touched: modifier matching (
MemberAccessMatcherFilter+MemberStateMatcherFilter) already evaluatespublic|protected+staticcorrectly as(public || protected) && static, so the goaop/framework#293 variant of this bug does not exist in the plugin.Tests
OrPointcutKindMatchingTestregression suite using realSignaturePointcuts that mirrors the issue scenario: cross-kind false positives are rejected while legitimate matches of each clause still work,TruePointcut(KIND_CLASS)no longer leaks members through an OR, and the OR kind stays the union (whichPointcutAdvisor.getMatchedElementsrelies on).AndPointcutTest/OrPointcutTestverifying the gate short-circuits before the sub-pointcut is consulted, and that only the kind-compatible child is delegated to.supports()coverage inKindFilterTest; kind-mismatch cases inSignaturePointcutTest.PhpClassMembertoMethodso they represent real PSI elements and pass the stricter gate.🤖 Generated with Claude Code
https://claude.ai/code/session_015GwCyE8P8udW5VMJHY4qGk
Generated by Claude Code