File tree Expand file tree Collapse file tree 11 files changed +168
-14
lines changed
change_instance_format7_ddc
change_instance_format7_vm Expand file tree Collapse file tree 11 files changed +168
-14
lines changed Original file line number Diff line number Diff line change 99export 'src/_reload_utils_api.dart'
1010 if (dart.library.io) 'src/_vm_reload_utils.dart'
1111 if (dart.library.js_interop) 'src/_ddc_reload_utils.dart' ;
12+
13+ bool get isVmRuntime => const bool .fromEnvironment ('dart.library.io' );
14+
15+ bool get isDdcRuntime => const bool .fromEnvironment ('dart.library.js_interop' );
Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ import 'package:reload_test/reload_test_utils.dart';
1010
1111// Tests reload succeeds when instance format changes.
1212// Change: Bar {c:42}, Foo : Bar {d, e} -> Foo {c:42}
13- // Validate: c keeps the value in the retained Foo object.
13+ // In the VM: c keeps the value in the retained Foo object.
14+ // For DDC: c adopts the value in the newly declared field in Bar.
1415
1516class Bar {
1617 var c;
@@ -29,5 +30,9 @@ Future<void> main() async {
2930 Expect .equals (42 , f.c);
3031 await hotReload ();
3132
32- Expect .equals (42 , f.c);
33+ if (isVmRuntime) {
34+ Expect .equals (42 , f.c);
35+ } else if (isDdcRuntime) {
36+ Expect .isNull (f.c);
37+ }
3338}
Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ import 'package:reload_test/reload_test_utils.dart';
1010
1111// Tests reload succeeds when instance format changes.
1212// Change: Bar {c:42}, Foo : Bar {d, e} -> Foo {c:42}
13- // Validate: c keeps the value in the retained Foo object.
13+ // In the VM: c keeps the value in the retained Foo object.
14+ // For DDC: c adopts the value in the newly declared field in Bar.
1415
1516class Foo {
1617 var c;
@@ -24,13 +25,17 @@ Future<void> main() async {
2425 Expect .equals (42 , f.c);
2526 await hotReload ();
2627
27- Expect .equals (42 , f.c);
28+ if (isVmRuntime) {
29+ Expect .equals (42 , f.c);
30+ } else if (isDdcRuntime) {
31+ Expect .isNull (f.c);
32+ }
2833}
2934
3035/** DIFF **/
3136/*
32- // Change: Bar {c:42}, Foo : Bar {d, e} -> Foo {c:42}
33- // Validate : c keeps the value in the retained Foo object .
37+ // In the VM: c keeps the value in the retained Foo object.
38+ // For DDC : c adopts the value in the newly declared field in Bar .
3439
3540-class Bar {
3641+class Foo {
Original file line number Diff line number Diff line change 1+ {
2+ "exclude" : [" vm" ],
3+ "expectedErrors" : {
4+ "1" : " type parameters have changed"
5+ }
6+ }
Original file line number Diff line number Diff line change 1+ // Copyright (c) 2025, 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:expect/expect.dart' ;
6+ import 'package:reload_test/reload_test_utils.dart' ;
7+
8+ // Adapted from:
9+ // https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L4051
10+
11+ // Tests reload succeeds when type parameters are changed for allocated class.
12+ // Change: Foo<A,B> {a, b} -> Foo<A> {a}
13+ // Validate: return value from main is correct.
14+ // This test is rejected at compile-time in DDC (vs at runtime for the VM).
15+
16+ class Foo <A , B > {
17+ var a;
18+ var b;
19+ }
20+
21+ Future <void > main () async {
22+ await hotReload (expectRejection: true );
23+ }
Original file line number Diff line number Diff line change 1+ // Copyright (c) 2025, 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:expect/expect.dart' ;
6+ import 'package:reload_test/reload_test_utils.dart' ;
7+
8+ // Adapted from:
9+ // https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L4051
10+
11+ // Tests reload succeeds when type parameters are changed for allocated class.
12+ // Change: Foo<A,B> {a, b} -> Foo<A> {a}
13+ // Validate: return value from main is correct.
14+ // This test is rejected at compile-time in DDC (vs at runtime for the VM).
15+
16+ class Foo <A > {
17+ var a;
18+ }
19+
20+ Future <void > main () async {
21+ await hotReload (expectRejection: true );
22+ }
23+
24+ /** DIFF **/
25+ /*
26+ // Validate: return value from main is correct.
27+ // This test is rejected at compile-time in DDC (vs at runtime for the VM).
28+
29+ -class Foo<A, B> {
30+ +class Foo<A> {
31+ var a;
32+ - var b;
33+ }
34+
35+ Future<void> main() async {
36+ */
Original file line number Diff line number Diff line change 1+ {
2+ "exclude" : [" d8" , " chrome" ]
3+ }
4+
Original file line number Diff line number Diff line change 1+ // Copyright (c) 2025, 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:expect/expect.dart' ;
6+ import 'package:reload_test/reload_test_utils.dart' ;
7+
8+ // Adapted from:
9+ // https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L4051
10+
11+ // Tests reload succeeds when type parameters are changed for allocated class.
12+ // Change: Foo<A,B> {a, b} -> Foo<A> {a}
13+ // Validate: return value from main is correct.
14+ // Please note: This test works because no instances are created from Foo.
15+
16+ class Foo <A , B > {
17+ var a;
18+ var b;
19+ }
20+
21+ Future <void > main () async {
22+ await hotReload ();
23+ }
Original file line number Diff line number Diff line change 1+ // Copyright (c) 2025, 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:expect/expect.dart' ;
6+ import 'package:reload_test/reload_test_utils.dart' ;
7+
8+ // Adapted from:
9+ // https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L4051
10+
11+ // Tests reload succeeds when type parameters are changed for allocated class.
12+ // Change: Foo<A,B> {a, b} -> Foo<A> {a}
13+ // Validate: return value from main is correct.
14+ // Please note: This test works because no instances are created from Foo.
15+
16+ class Foo <A > {
17+ var a;
18+ }
19+
20+ Future <void > main () async {
21+ await hotReload ();
22+ }
23+
24+ /** DIFF **/
25+ /*
26+ // Validate: return value from main is correct.
27+ // Please note: This test works because no instances are created from Foo.
28+
29+ -class Foo<A, B> {
30+ +class Foo<A> {
31+ var a;
32+ - var b;
33+ }
34+
35+ Future<void> main() async {
36+ */
Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ import 'package:reload_test/reload_test_utils.dart';
88// Adapted from:
99// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L917
1010
11+ // B gets its implementation of 'func' from mixin2.
12+ // For the VM, the saved instance of B retains its old field value from mixin1.
13+ // For DDC, the field is updated to read from mixin2's.
14+
1115mixin Mixin1 {
1216 var field = 'mixin1' ;
1317 func () => 'mixin1' ;
@@ -21,10 +25,12 @@ Future<void> main() async {
2125 Expect .equals ('mixin1' , saved.func ());
2226 await hotReload ();
2327
24- // The saved instance of B retains its old field value from mixin1,
25- // but it gets the new implementation of func from mixin2.
2628 var newer = B ();
27- Expect .equals ('mixin1' , saved.field);
29+ if (isVmRuntime) {
30+ Expect .equals ('mixin1' , saved.field);
31+ } else if (isDdcRuntime) {
32+ Expect .equals ('mixin2' , saved.field);
33+ }
2834 Expect .equals ('mixin2' , saved.func ());
2935 Expect .equals ('mixin2' , newer.field);
3036 Expect .equals ('mixin2' , newer.func ());
You can’t perform that action at this time.
0 commit comments