- // Special case where parent class is used to emit instance method
- // because currect storey is of value type (async host) and we don't
- // want to create another childer storey to host this reference only
+ // Remove hoisted 'this' request when simple instance method is
+ // enough. No hoisted variables only 'this' and don't need to
+ // propagate this to value type state machine.
+ //
+ StateMachine sm_parent;
+ var pb = src_block.ParametersBlock;
+ do {
+ sm_parent = pb.StateMachine;
+ pb = pb.Parent == null ? null : pb.Parent.ParametersBlock;
+ } while (sm_parent == null && pb != null);
+
+ if (sm_parent == null) {
+ top_block.RemoveThisReferenceFromChildrenBlock (src_block);
+ } else if (sm_parent.Kind == MemberKind.Struct) {
+ //
+ // Special case where parent class is used to emit instance method
+ // because currect storey is of value type (async host) and we cannot
+ // use ldftn on non-boxed instances either to share mutated state
+ //
+ parent = sm_parent.Parent.PartialContainer;
+ }
+ } else {