Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

Allow Volatile::extend() to work as expected #874

Merged
merged 1 commit into from
Aug 31, 2018

Conversation

dktapps
Copy link
Contributor

@dktapps dktapps commented Jun 6, 2018

Threaded objects are often poorly suited for runtime class extension because of their immutability characteristics. Classes which are not Threaded need to be adapted to extend Threaded (for example, overwriting a coerced array on a runtime-extended class crashes).

Because Volatile descends from Threaded, Volatile::extend() exists, but does not work as might be expected - it behaves exactly the same as Threaded::extend().

This PR changes Threaded::extend() to apply the scope it was called from, instead of always applying the Threaded parent.

A possible alternative to this could be to simply move extend() to Volatile completely, since as I said above Threaded isn't suited to code that doesn't know it's Threaded anymore due to immutability.

@sirsnyder
Copy link
Collaborator

To keep Volatile and Threaded consistent, I prefer the way of this PR.

@sirsnyder sirsnyder merged commit 598824d into krakjoe:master Aug 31, 2018
@sirsnyder
Copy link
Collaborator

Thanks @dktapps !

@dktapps dktapps deleted the runtime-extend-non-threaded branch August 31, 2018 08:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants