[vm] Adds offsets to sync gen.
Sync generators contain two implicit wrappers (:sync_op_gen
and :sync_op), which do not directly correspond to any user
code - and therefore do not have fileOffsets.
Some tools however rely on fileOffsets to e.g. compute code
coverage, so this change adds fileOffset inherited from the
non-synthetic code to :sync_op_gen and :sync_op.
Bug: https://github.com/dart-lang/sdk/issues/47681
Change-Id: I0c54bc3eaf5892e591fead845b5d31d2dfc9481f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220543
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
diff --git a/pkg/kernel/lib/transformations/continuation.dart b/pkg/kernel/lib/transformations/continuation.dart
index e9d5c3c..d6ef537 100644
--- a/pkg/kernel/lib/transformations/continuation.dart
+++ b/pkg/kernel/lib/transformations/continuation.dart
@@ -442,7 +442,8 @@
type: FunctionType([], syncOpType, staticTypeContext.nonNullable));
final syncOpVariable = VariableDeclaration(ContinuationVariables.syncOp);
- final syncOpDecl = FunctionDeclaration(syncOpVariable, syncOpFN);
+ final syncOpDecl = FunctionDeclaration(syncOpVariable, syncOpFN)
+ ..fileOffset = enclosingFunction.fileOffset;
enclosingFunction.body = Block([
// :sync_op_gen() {
@@ -466,7 +467,8 @@
// return sync_op;
ReturnStatement(VariableGet(syncOpVariable)),
]),
- returnType: syncOpType)),
+ returnType: syncOpType))
+ ..fileOffset = enclosingFunction.fileOffset,
// return _SyncIterable<T>(:sync_op_gen);
ReturnStatement(ConstructorInvocation(