Skip to content

Commit 34ebfc6

Browse files
fishythefishCommit Bot
authored and
Commit Bot
committed
[dart2js] Add regression test for https://dart-review.googlesource.com/c/sdk/+/225320
Change-Id: Iff348b9ce13ea249b8c63f8c0952cd446ad5cb7d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243528 Commit-Queue: Mayank Patke <[email protected]> Reviewed-by: Sigmund Cherem <[email protected]>
1 parent e5498bc commit 34ebfc6

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'package:compiler/src/util/testing.dart';
6+
7+
/*member: Foo.:[exact=Foo]*/
8+
class Foo {
9+
/*member: Foo._#Foo#x:[sentinel|exact=JSUInt31]*/
10+
/*member: Foo.x:[exact=JSUInt31]*/
11+
late int /*[exact=Foo]*/ /*update: [exact=Foo]*/ x = 42;
12+
}
13+
14+
/*member: main:[null]*/
15+
void main() {
16+
makeLive(test(Foo()));
17+
}
18+
19+
@pragma('dart2js:noInline')
20+
/*member: test:[exact=JSUInt31]*/
21+
int test(Foo /*[exact=Foo]*/ foo) => foo. /*[exact=Foo]*/ x;

tests/web/late_no_inlining_test.dart

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// dart2jsOptions=--disable-inlining
6+
7+
import 'package:expect/expect.dart';
8+
9+
// Tests to ensure that narrowing type information does not discard late
10+
// sentinel values unintentionally.
11+
12+
class Foo {
13+
late int bar = 42;
14+
late final int baz = 1729;
15+
}
16+
17+
void main() {
18+
final foo = Foo();
19+
Expect.equals(42, foo.bar);
20+
Expect.equals(1729, foo.baz);
21+
}

0 commit comments

Comments
 (0)