pharo icon indicating copy to clipboard operation
pharo copied to clipboard

[RB] Extract method with non local returns breaks

Open guillep opened this issue 2 years ago • 1 comments

  • Given
myMethod

	self condition
		ifTrue: [ ^ 0 ]
		ifFalse: [ ^ 1 ]
  • Select the entire method body self condition ifTrue: [ ^ 0 ] ifFalse: [ ^ 1 ]
  • Extract method using the (R) Extract method and occurrences option with selector foo

This will create =>

myMethod

    self foo

foo
	self condition
		ifTrue: [ ^ 0 ]
		ifFalse: [ ^ 1 ]

Which is incorrect because now myMethod returns self instead of 0 or 1

guillep avatar Feb 15 '24 09:02 guillep

Tx :)

Ducasse avatar Feb 15 '24 10:02 Ducasse

We should check if this is the refactoring or the transformation.

Ducasse avatar Feb 19 '24 18:02 Ducasse

it's the refactoring 100% sure

guillep avatar Feb 19 '24 18:02 guillep