smalltalk: Object>>becomeForward: + 6 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-25 09:54:40 +00:00
parent 3e83624317
commit fdd8e18cc3
3 changed files with 83 additions and 1 deletions

View File

@@ -565,6 +565,24 @@
(cond
((not (st-class-ref? arg)) false)
(else (= target-cls (get arg :name))))))
;; Object>>becomeForward: aReceiver — one-way become. The receiver's
;; class and ivars are mutated in place to match the target. Every
;; existing reference to the receiver dict sees the new identity.
;; Note: receiver and target remain distinct dicts (not == in the
;; SX-identity sense), but receiver behaves as though it were the
;; target — which is the practical Pharo guarantee.
((= selector "becomeForward:")
(let ((other (nth args 0)))
(cond
((not (st-instance? receiver))
(error "becomeForward: only supported on user instances"))
((not (st-instance? other))
(error "becomeForward: target must be a user instance"))
(else
(begin
(dict-set! receiver :class (get other :class))
(dict-set! receiver :ivars (get other :ivars))
receiver)))))
((or (= cls "SmallInteger") (= cls "Float"))
(st-num-send receiver selector args))
((or (= cls "String") (= cls "Symbol"))