[squeak-dev] The Trunk: Collections-jr.855.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Sep 25 14:08:15 UTC 2019


Marcel Taeumel uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-jr.855.mcz

==================== Summary ====================

Name: Collections-jr.855
Author: jr
Time: 25 September 2019, 3:23:14.995261 pm
UUID: 9a5b562f-ca9a-624c-9012-7840cb25db4e
Ancestors: Collections-mt.854

Catch the lookup of nil in WeakKeyDictionary

While no nil key can be added, keys become nil when they are garbage collected. This must not let nil accidentally "inherit" the value of such a stale association.

It only happens in unfortunate situations when nil and the collected key would hash to the same place in the hash table (array). Yet it does happen.

=============== Diff against Collections-mt.854 ===============

Item was added:
+ ----- Method: WeakKeyDictionary>>at:ifAbsent: (in category 'accessing') -----
+ at: key ifAbsent: aBlock 
+ 	"While no nil key can be added, keys become nil when they are garbage collected.
+ 	This must not let nil accidentally 'inherit' the value of such a stale association."
+ 	key ifNil: [^ aBlock value].
+ 	^ super at: key ifAbsent: aBlock!



More information about the Squeak-dev mailing list