Skip to content

Commit

Permalink
try to fix undeclared loading
Browse files Browse the repository at this point in the history
  • Loading branch information
demarey committed May 29, 2024
1 parent 65f147e commit 3bd7046
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/PharoLauncher-100Compatibility/SystemDictionary.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Extension { #name : 'SystemDictionary' }

{ #category : '*PharoLauncher-100Compatibility' }
SystemDictionary >> at: aKey put: anObject [
"Override from Dictionary to check Undeclared and fix up
references to undeclared variables."
| index assoc registeredMethods |
aKey isSymbol ifFalse: [ self error: 'Only symbols are accepted as keys in SystemDictionary' ].
registeredMethods := #().
((self includesKey: aKey) not and: [ Undeclared includesKey: aKey ]) ifTrue: [
| undeclared |
undeclared := Undeclared associationAt: aKey.
"Undeclared variables record using methods in a property, remove. Boostrap might have used Associations"
(undeclared class == UndeclaredVariable) ifTrue: [
registeredMethods := undeclared removeProperty: #registeredMethods ifAbsent: [ #() ]].
"and change class to be Global"
self add: (undeclared primitiveChangeClassTo: GlobalVariable new).
Undeclared removeKey: aKey].
"code of super at:put:, not using Associations but GlobalVariable"
index := self findElementOrNil: aKey.
assoc := array at: index.
assoc
ifNil: [self atNewIndex: index put: (GlobalVariable key: aKey value: anObject). self flushClassNameCache]
ifNotNil: [assoc value: anObject].
registeredMethods do: [ :aMethod | aMethod isInstalled ifTrue: [aMethod recompile] ].
^ anObject
]

0 comments on commit 3bd7046

Please sign in to comment.