Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RB methodDefiningTemporary: aString in: aClass ignore has a strange logic #17753

Open
Ducasse opened this issue Feb 2, 2025 · 0 comments
Open

Comments

@Ducasse
Copy link
Member

Ducasse commented Feb 2, 2025

First it iterates in all the subclasses? and this is really unclear in the method name

methodDefiningTemporary: aString in: aClass ignore: aBlock

	| searcher method |
	searcher := OCParseTreeSearcher new.
	method := nil. "Shut-up the warning"
	searcher matches: aString do: [ :aNode :answer | ^ method ].
	aClass withAllSubclasses do: [ :class |
		class selectors do: [ :each |
			(aBlock value: class value: each) ifFalse: [
				| parseTree |
				method := class methodFor: each.
				parseTree := class parseTreeForSelector: each.
				parseTree ifNotNil: [ searcher executeTree: parseTree ] ] ] ].
	^ nil

Second users seems to cancel the subclass navigation

definesTempVar: aString in: aClass ignoreClass: subclass

	| condition |
	condition := self new.
	condition
		block: [
			| method |
			method := self
				          methodDefiningTemporary: aString
				          in: aClass
				          ignore: [ :class :aSelector |
				          class includesClass: subclass ].
			method ifNotNil: [
				condition errorMacro:
					method printString , ' defines variable ' , aString ].
			method isNotNil ]
		errorString:
			aClass printString
			, ' <1?:does not >define<1?s:> temporary variable ' , aString.
	^ condition

Third what is aClass includesClass: subclass.
It looks like a bad name

includesClass: aRBClass
	| currentClass |
	currentClass := self.
	[currentClass isNotNil and: [currentClass ~= aRBClass]]
		whileTrue: [currentClass := currentClass superclass].
	^currentClass = aRBClass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant