From aaa66ed77ea8b7582ab478ad4425dadcec4a5b02 Mon Sep 17 00:00:00 2001 From: Nicholas Shahan Date: Wed, 7 Apr 2021 18:04:27 +0000 Subject: [PATCH] [ddc] Fix sourcemap on debugger statements Add test file exercising the lack of distinct sourcemaps. Change-Id: I35e099b2a91d5b6516adaa3cb034ab0b84262fed Fixes: https://github.com/dart-lang/sdk/issues/45544 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194019 Reviewed-by: Mark Zhou Reviewed-by: Sigmund Cherem Commit-Queue: Nicholas Shahan --- pkg/dev_compiler/lib/src/kernel/compiler.dart | 5 ++-- .../testfiles/multiple_debugger_calls.dart | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 pkg/dev_compiler/test/sourcemap/testfiles/multiple_debugger_calls.dart diff --git a/pkg/dev_compiler/lib/src/kernel/compiler.dart b/pkg/dev_compiler/lib/src/kernel/compiler.dart index dcec2b1ce77..cf0461ac19b 100644 --- a/pkg/dev_compiler/lib/src/kernel/compiler.dart +++ b/pkg/dev_compiler/lib/src/kernel/compiler.dart @@ -5294,8 +5294,9 @@ class ProgramCompiler extends ComputeOnceConstantVisitor // Inline `debugger()` with no arguments, as a statement if possible, // otherwise as an immediately invoked function. return isStatement - ? js.statement('debugger;') - : js.call('(() => { debugger; return true})()'); + ? js_ast.DebuggerStatement() + : js.call( + '(() => { #; return true})()', [js_ast.DebuggerStatement()]); } // The signature of `debugger()` is: diff --git a/pkg/dev_compiler/test/sourcemap/testfiles/multiple_debugger_calls.dart b/pkg/dev_compiler/test/sourcemap/testfiles/multiple_debugger_calls.dart new file mode 100644 index 00000000000..4a82e371754 --- /dev/null +++ b/pkg/dev_compiler/test/sourcemap/testfiles/multiple_debugger_calls.dart @@ -0,0 +1,24 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// @dart = 2.9 + +import 'dart:developer'; + +void main() { + print('1'); + /*sl:1*/ debugger(); + print('2'); + /*sl:2*/ debugger(); + print('3'); + foo(/*s:3*/ debugger()); + print('4'); + /*sl:4*/ debugger(); + print('5'); + foo(/*s:5*/ debugger()); + print('6'); + foo(/*s:6*/ debugger()); +} + +void foo(bool _) => null;