McpScriptConfigurator
Configures an execute_code snippet as a FirScript whose whole body is the body of one lambda, invoked on the spot: ({ body })(), the inside of a run { }. SnippetParser parses the text under function-body rules and wraps all of it in a single script initializer, which the stock light-tree converter turns into one block of local declarations and statements; this moves that block into the lambda. There, data flow runs from each statement into the next and a var is a local — the two things a smart cast needs, and neither of which a script's class-body top level gives it.
The reshaping is for a lowered script, one that goes on through fir2ir to the backend. Analysis leaves the body the initializer it parses to: LL FIR rebuilds every body it resolves from PSI, which holds no lambda, and rebuilds a result property's value only out of an initializer that is a single expression. An initializer is a data-flow root as well; it is fir2ir that needs the lambda.
Functions
({ body })() — the body of a lambda, as in run { }, invoked on the spot. A lambda is a root for the data-flow analysis: what decides whether a var a closure writes may still smart-cast. A property initializer is no root, so it would let such a smart cast through; the anonymous initializer the body arrives in is one, but fir2ir flattens it into the script's top level, where every local variable becomes a property. The backend inlines a lambda invoked on the spot, so the body still runs straight in the constructor.
The property holding the snippet's value: value's, the body's last expression under the type it resolved to. A body ending on a statement makes that Unit, and fir2ir then emits the invocation as a plain statement and no property at all — so a snippet has a result exactly when it ends on a value, with nothing here deciding which.