@@ -50,15 +50,16 @@ fn main() {
50
50
expect. When we call my_outer.z(), we should also get 3, because
51
51
at no point is z being overridden.
52
52
53
- To fix this bug, we need to add a second level of forwarding
54
- functions (let's call them "backwarding functions") on the inner
55
- object. Every time an object is extended with another object, we
56
- have to rewrite the inner object's vtable to account for the fact
57
- that future self-calls will get a larger object. The inner
58
- object's vtable will need to have five slots, too. The ones for b
59
- and n will point right back at the outer object. (These are the
60
- "backwarding" ones.) And the ones for a, m, and z will point at
61
- the original, real vtable for inner.
53
+ To fix this bug, we need to make the vtable slots on the inner
54
+ object match whatever the object being passed in at runtime has.
55
+ My first instinct was to change the vtable to match the runtime
56
+ object, but vtables are already baked into RO memory. So, instead,
57
+ we're going to tweak the object being passed in at runtime to match
58
+ the vtable that inner already has. That is, it needs to only have
59
+ a, m, and z slots in its vtable, and each one of those slots will
60
+ forward to the *outer* object's a, m, and z slots, respectively.
61
+ From there they will either head right back to inner, or they'll be
62
+ overridden.
62
63
63
64
Adding support for this is issue #702.
64
65
0 commit comments