smalltalk: Object>>becomeForward: + 6 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user