Hi Eliot,
I am pretty sure this is not a vm issue :)
The mustBeBooleanInMagic: creates a method on the fly and executes it with the
a context as argument.
The "ThisContext" is not the "thisContext", but the argument of the generated method.
This is the bytecode of the generated method:
17 <00> pushRcvr: 0
18 <8F 00 00 02> closureNumCopied: 0 numArgs: 0 bytes 22 to 23
22 <76> pushConstant: 1
23 <7D> blockReturn
24 <8F 00 00 02> closureNumCopied: 0 numArgs: 0 bytes 28 to 29
28 <75> pushConstant: 0
29 <7D> blockReturn
30 <F0> send: ifTrue:ifFalse:
31 <7C> returnTop
The original method is
foo
^ notABool1 ifTrue:[1] ifFalse:[0]
The generated method compiles this part
notABool1 ifTrue:[1] ifFalse:[0]
to bytecode without the jumpFalse optimization.
The problem is that the receiver for the ifTrue:ifFalse send is accessed through
pushRcvr:0, whereas the thisContext is not the context of the original method anymore.
Nicolai