The Trunk: Kernel-nice.798.mcz

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

The Trunk: Kernel-nice.798.mcz

commits-2
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.798.mcz

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

Name: Kernel-nice.798
Author: nice
Time: 30 July 2013, 10:34:15.34 pm
UUID: e02ae597-3f6d-40b9-9468-bf01416db6de
Ancestors: Kernel-nice.797

Better fix for http://bugs.squeak.org/view.php?id=1554
A class variable defined in a superclass should take precedence over a global variable.

First look in local class variables.
Then look in local sharedPools (a local sharedPool will shadow a super class variable, that sounds fair).
Then look in superclass pools.
When superclass chain is exhausted, look in the Environment that were provided as parameter.

Note that this is mostly squeak 1.x implementation of #scopeHas:ifTrue: (or st-80), except that anEvironment parameter replaces Smalltalk.
This way we avoid duplicate lookup of previous workaround.
And we never ever look in superclass environment, that's not necessarily ours.

This currently breaks some EnvironmentTest because inheriting superclass environment is a cheap and easy way to  import all Smalltalk (unless you are not an Object or ProtoObject of course).
The longest and proper way would be to properly export some symbols from Smalltalk globals, and import them explicitely in the tested environment.

=============== Diff against Kernel-nice.797 ===============

Item was changed:
  ----- Method: Class>>bindingOf:environment: (in category 'compiling') -----
  bindingOf: varName environment: anEnvironment
  "Answer the binding of some variable resolved in the scope of the receiver"
  | aSymbol binding |
  aSymbol := varName asSymbol.
 
+ "First look in local classVar dictionary."
+ binding := self classPool bindingOf: aSymbol.
+ binding ifNotNil:[^binding].
- "First look in classVar dictionary."
- (self classThatDefinesClassVariable: aSymbol) ifNotNil:
- [:x | ^x classPool bindingOf: aSymbol].
 
+ "Next look in local shared pools."
- "Next look in shared pools."
  self sharedPools do:[:pool |
  binding := pool bindingOf: aSymbol.
  binding ifNotNil:[^binding].
  ].
 
+ "Next look into superclass pools"
+ superclass ifNotNil: [^ superclass bindingOf: aSymbol environment: anEnvironment].
+
+ "No more superclass... Last look in declared environment."
+ ^anEnvironment bindingOf: aSymbol
- "Next look in declared environment."
- binding := anEnvironment bindingOf: aSymbol.
- binding ifNotNil:[^binding].
 
- "Finally look higher up the superclass chain and fail at the end."
- superclass == nil
- ifTrue: [^ nil]
- ifFalse: [^ superclass bindingOf: aSymbol].
-
  !