#BUGFIX by stefan
class: WeakIdentityDictionary
changed:6 methods
check for SmallInteger keys
--- a/WeakIdentityDictionary.st Thu Jul 21 15:50:52 2016 +0200
+++ b/WeakIdentityDictionary.st Thu Jul 21 15:51:19 2016 +0200
@@ -77,15 +77,20 @@
|val|
+ key class == SmallInteger ifTrue:[
+ "SmallIntegers cannot be stored into a WeakArray"
+ ^ exceptionBlock value.
+ ].
+
(OperatingSystem blockInterrupts) ifTrue:[
- "/ already blocked
- ^ super at:key ifAbsent:exceptionBlock.
+ "/ already blocked
+ ^ super at:key ifAbsent:exceptionBlock.
].
[
- val := super at:key ifAbsent:exceptionBlock.
+ val := super at:key ifAbsent:exceptionBlock.
] ensure:[
- OperatingSystem unblockInterrupts.
+ OperatingSystem unblockInterrupts.
].
^ val
@@ -99,6 +104,11 @@
|val|
+ key class == SmallInteger ifTrue:[
+ "SmallIntegers cannot be stored into a WeakArray"
+ self error:'WeakidentityDictionary: cannot store a SmallInteger'.
+ ].
+
(OperatingSystem blockInterrupts) ifTrue:[
"/ already blocked
^ super at:key ifAbsentPut:replacementBlock.
@@ -120,15 +130,20 @@
|val|
+ key class == SmallInteger ifTrue:[
+ "SmallIntegers cannot be stored into a WeakArray"
+ self error:'WeakidentityDictionary: cannot store a SmallInteger'.
+ ].
+
(OperatingSystem blockInterrupts) ifTrue:[
- "/ already blocked
- ^ super at:key put:anObject.
+ "/ already blocked
+ ^ super at:key put:anObject.
].
[
- val := super at:key put:anObject.
+ val := super at:key put:anObject.
] ensure:[
- OperatingSystem unblockInterrupts.
+ OperatingSystem unblockInterrupts.
].
^ val
@@ -148,15 +163,20 @@
|ret|
+ aKey class == SmallInteger ifTrue:[
+ "SmallIntegers cannot be stored into a WeakArray"
+ ^ aBlock value.
+ ].
+
(OperatingSystem blockInterrupts) ifTrue:[
- "/ already blocked
- ^ super removeKey:aKey ifAbsent:aBlock.
+ "/ already blocked
+ ^ super removeKey:aKey ifAbsent:aBlock.
].
[
- ret := super removeKey:aKey ifAbsent:aBlock
+ ret := super removeKey:aKey ifAbsent:aBlock
] ensure:[
- OperatingSystem unblockInterrupts
+ OperatingSystem unblockInterrupts
].
^ ret
@@ -170,15 +190,20 @@
|val|
+ key class == SmallInteger ifTrue:[
+ "SmallIntegers cannot be stored into a WeakArray"
+ ^ nil.
+ ].
+
(OperatingSystem blockInterrupts) ifTrue:[
- "/ already blocked
- ^ super safeRemoveKey:key.
+ "/ already blocked
+ ^ super safeRemoveKey:key.
].
[
- val := super safeRemoveKey:key.
+ val := super safeRemoveKey:key.
] ensure:[
- OperatingSystem unblockInterrupts.
+ OperatingSystem unblockInterrupts.
].
^ val
@@ -406,15 +431,20 @@
|val|
+ key class == SmallInteger ifTrue:[
+ "SmallIntegers cannot be stored into a WeakArray"
+ ^ false.
+ ].
+
(OperatingSystem blockInterrupts) ifTrue:[
- "/ already blocked
- ^ super includesKey:key.
+ "/ already blocked
+ ^ super includesKey:key.
].
[
- val := super includesKey:key.
+ val := super includesKey:key.
] ensure:[
- OperatingSystem unblockInterrupts.
+ OperatingSystem unblockInterrupts.
].
^ val