[vm,dyn_modules] Fix the starting file offset for closure functions.

For closures generated from both FunctionDeclarations and
FunctionExpressions, the starting file offset of the generated closure
function should be the file offset of the node itself, not the file
offset of the FunctionNode.

(This matches the logic in KernelLoader::LoadClosureFunction.)

TEST=pkg/vm_service/test/coverage_extension_methods_test

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Change-Id: I25a0cd0aa6505e122a215237ca6ef7e8edb031af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507424
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
This commit is contained in:
Tess Strickland
2026-06-01 10:35:58 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent 1276c57803
commit 7b5f8df929
@@ -2865,9 +2865,7 @@ class BytecodeGenerator extends RecursiveVisitor {
int position = TreeNode.noOffset;
int endPosition = TreeNode.noOffset;
if (options.emitSourcePositions) {
position = (node is ast.FunctionDeclaration)
? node.fileOffset
: function.fileOffset;
position = node.fileOffset;
endPosition = function.fileEndOffset;
if (position != TreeNode.noOffset) {
flags |= ClosureDeclaration.hasSourcePositionsFlag;