Skip to content
This repository was archived by the owner on Jan 26, 2021. It is now read-only.

Commit 7c60fb7

Browse files
committed
Fix implementation of checked in benchmark code
Per discussion #126 (review)
1 parent ac7a2f5 commit 7c60fb7

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

benchmark/lib/report.dart

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,22 @@ pb.Response findUpdatedResponse(pb.Report beforeRep, pb.Report afterRep) {
3232
pb.Platform createPlatform() {
3333
return new pb.Platform()
3434
..dartVM = _isDartVM
35-
..checkedMode = _checkedMode;
35+
..checkedMode = _implicitChecksEnabled;
3636
}
3737

3838
get _isDartVM => !identical(1, 1.0);
3939

40-
final bool _checkedMode = () {
41-
var checked = false;
42-
assert(() {
43-
checked = true;
40+
/// Returns `false` if running via dart2js and `--omit-implicit-checks` is set
41+
final bool _implicitChecksEnabled = () {
42+
// ignore: unused_local_variable
43+
bool x = true;
44+
try {
45+
// Trigger an exception if we're in checked mode.
46+
x = "" as dynamic;
47+
return false;
48+
} catch (e) {
4449
return true;
45-
}());
46-
return checked;
50+
}
4751
}();
4852

4953
/// Given the contents of the pubspec.yaml and pubspec.lock files,

build.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ targets:
66
build_web_compilers|entrypoint:
77
generate_for:
88
- benchmark/*_browser.dart
9+
options:
10+
dart2js_args:
11+
- --minify
12+
#- --trust-primitives
13+
#- --omit-implicit-checks

0 commit comments

Comments
 (0)