[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 <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
This commit is contained in:
Nicholas Shahan
2021-04-07 18:04:27 +00:00
committed by commit-bot@chromium.org
parent 81c87c5f2b
commit aaa66ed77e
2 changed files with 27 additions and 2 deletions
@@ -5294,8 +5294,9 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
// 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:
@@ -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;