Skip to content

Generic nonViolators for ReConditions#18645

Merged
Ducasse merged 4 commits intopharo-project:Pharo14from
carolahp:refactor/generic-non-violatos
Oct 9, 2025
Merged

Generic nonViolators for ReConditions#18645
Ducasse merged 4 commits intopharo-project:Pharo14from
carolahp:refactor/generic-non-violatos

Conversation

@carolahp
Copy link
Copy Markdown
Contributor

@carolahp carolahp commented Oct 9, 2025

This is a follow up from @balsa-sarenac comment in #PR18497... We should merge this one before the one in the link.

This PR is the first step to implement a generic method nonViolators for conditions.
To do so I have introduced the accessor subjects in conditions. Subjects are candidates to be violators.
Normally subjects should be overriden only by abstract classes such as ReClassesCondition or ReMethodsCondition, because their subclasses handle different kinds of violators (i.e.: classes and methods). However there are exceptions (check ReClassesExistCondition). This, nonViolators are computed as the difference between subjects and violators.

I added tests for all subclasses of ReClassesCondition , where I check for nonViolators and also for the condition's error string.

By overriding subjects, negated conditions can also use the generic implementation of nonViolators.
More tests for complex conditions are required

@carolahp carolahp requested review from Ducasse and balsa-sarenac and removed request for balsa-sarenac October 9, 2025 09:49
…ects (methods in ReNegation are temporary while we create a single hierarchy for conditions)
Comment on lines 1536 to -1621
@@ -1614,11 +1609,6 @@ SequenceableCollection >> middle [
^ self at: self size // 2 + 1
]

{ #category : 'comparing' }
SequenceableCollection >> min: aSelectorOrOneArgBlock [
^ (self collect: aSelectorOrOneArgBlock) min
]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming these got deleted by mistake

Comment on lines +39 to +44
{ #category : 'accessing' }
ReReifiedCondition >> subjects [

self subclassResponsibility
]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be benefits of using accessor instead of instance variable?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carolahp my thinking was that if we have them as instance variables, every conditions will in its constructor define them. And I feel like this hook can be avoided then. Just to explain on why I asked this.

@Ducasse Ducasse merged commit 492814d into pharo-project:Pharo14 Oct 9, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants