diff --git a/src/Collections-Abstract/Collection.class.st b/src/Collections-Abstract/Collection.class.st index 1cc1d3da71c..3e92a5a44f0 100644 --- a/src/Collections-Abstract/Collection.class.st +++ b/src/Collections-Abstract/Collection.class.st @@ -891,11 +891,17 @@ Collection >> hash [ -- two equal objects have equal hash values" | hash | - hash := self species hash. - self size <= 10 ifTrue: - [self do: [:elem | hash := hash bitXor: elem hash]]. - ^hash bitXor: self size hash + self size <= 10 ifTrue: [ + | identity elemIdentityHash elemHash | + identity := self identityHash. + self do: [ :elem | + elemIdentityHash := elem identityHash. + elemHash := elemIdentityHash = identity + ifTrue: [ elemIdentityHash ] + ifFalse: [ elem hash ]. + hash := hash bitXor: elemHash ] ]. + ^ hash bitXor: self size hash ] { #category : 'testing' }