The Trunk: Collections-jr.855.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-jr.855.mcz

commits-2
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!