[squeak-dev] DeepCopier fix

Stéphane Rollandin lecteur at zogotounga.net
Tue Dec 2 20:37:50 UTC 2014


Hello,

I'm sending here a fix here for method DeepCopier>>fixDependents, which 
did not check that some weak associations may have a nil key. I have 
just got bitten by the bug, and the fix seemed straightforward.

Now I did not investigate further, but maybe the test for nil keys 
should be moved to a specific implementation of #associationsDo: in 
WeakIdentityKeyDictionary.

What do you think ?

(fix attached)


Stef
-------------- next part --------------
'From Squeak4.6 of 17 March 2014 [latest update: #13700] on 2 December 2014 at 9:31:56 pm'!

!DeepCopier methodsFor: 'like fullCopy' stamp: 'spfa 12/2/2014 13:49'!
fixDependents
	"They are not used much, but need to be right"

	DependentsFields associationsDo: [:pair |
		pair key ifNotNil: [
			pair value do: [:dep | 
				| newDep newModel |
				newDep := references at: dep ifAbsent: [nil].
				newDep ifNotNil: [
					newModel := references at: pair key ifAbsent: [pair key].
					newModel addDependent: newDep]]]]
! !


More information about the Squeak-dev mailing list