File tree 2 files changed +42
-0
lines changed
pkg/compiler/test/inference/data
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
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;
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments