diff --git a/tests/hot_reload/delete_static_field/config.json b/tests/hot_reload/delete_static_field/config.json new file mode 100644 index 00000000000..b72fb4b01b6 --- /dev/null +++ b/tests/hot_reload/delete_static_field/config.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} \ No newline at end of file diff --git a/tests/hot_reload/delete_static_field/main.0.dart b/tests/hot_reload/delete_static_field/main.0.dart new file mode 100644 index 00000000000..344ef8659f4 --- /dev/null +++ b/tests/hot_reload/delete_static_field/main.0.dart @@ -0,0 +1,35 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L5493 + +// Note: The original VM test checks for allocated objects on the heap after a +// hot reload. There isn't an obvious web analogue, so we've left this off +// unless this side effect becomes visible across platforms. + +class C { + int value = 42; +} + +class Foo { + static var x = C(); +} + +late var closure; + +helper() { + closure = () => Foo.x.value; +} + +Future main() async { + helper(); + Expect.equals(42, closure()); + await hotReload(); + + Expect.throws(closure); +} diff --git a/tests/hot_reload/delete_static_field/main.1.dart b/tests/hot_reload/delete_static_field/main.1.dart new file mode 100644 index 00000000000..9ca1acb530c --- /dev/null +++ b/tests/hot_reload/delete_static_field/main.1.dart @@ -0,0 +1,52 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L5493 + +// Note: The original VM test checks for allocated objects on the heap after a +// hot reload. There isn't an obvious web analogue, so we've left this off +// unless this side effect becomes visible across platforms. + +class C { + int value = 42; +} + +class Foo {} + +late var closure; + +helper() {} + +Future main() async { + helper(); + Expect.equals(42, closure()); + await hotReload(); + + Expect.throws(closure); +} +/** DIFF **/ +/* +@@ -16,15 +16,11 @@ + int value = 42; + } + +-class Foo { +- static var x = C(); +-} ++class Foo {} + + late var closure; + +-helper() { +- closure = () => Foo.x.value; +-} ++helper() {} + + Future main() async { + helper(); +*/ diff --git a/tests/hot_reload/existing_field_changes_type/config.json b/tests/hot_reload/existing_field_changes_type/config.json new file mode 100644 index 00000000000..b72fb4b01b6 --- /dev/null +++ b/tests/hot_reload/existing_field_changes_type/config.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} \ No newline at end of file diff --git a/tests/hot_reload/existing_field_changes_type/main.0.dart b/tests/hot_reload/existing_field_changes_type/main.0.dart new file mode 100644 index 00000000000..4ec158b895f --- /dev/null +++ b/tests/hot_reload/existing_field_changes_type/main.0.dart @@ -0,0 +1,23 @@ +// Copyright (c) 2024, 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. + +import 'dart:typed_data'; +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L5674 + +class Foo { + int x = 42; +} + +Future main() async { + Expect.type(Foo().x); + Expect.equals(42, Foo().x); + await hotReload(); + + Expect.type(Foo().x); + Expect.equals('42', Foo().x); +} diff --git a/tests/hot_reload/existing_field_changes_type/main.1.dart b/tests/hot_reload/existing_field_changes_type/main.1.dart new file mode 100644 index 00000000000..a613b8140a1 --- /dev/null +++ b/tests/hot_reload/existing_field_changes_type/main.1.dart @@ -0,0 +1,35 @@ +// Copyright (c) 2024, 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. + +import 'dart:typed_data'; +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L5674 + +class Foo { + String x = '42'; +} + +Future main() async { + Expect.type(Foo().x); + Expect.equals(42, Foo().x); + await hotReload(); + + Expect.type(Foo().x); + Expect.equals('42', Foo().x); +} +/** DIFF **/ +/* +@@ -10,7 +10,7 @@ + // https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L5674 + + class Foo { +- int x = 42; ++ String x = '42'; + } + + Future main() async { +*/ diff --git a/tests/hot_reload/existing_field_changes_type_indirect/main.0.dart b/tests/hot_reload/existing_field_changes_type_indirect/main.0.dart index 9991ff75d5d..5dc0d95deb6 100644 --- a/tests/hot_reload/existing_field_changes_type_indirect/main.0.dart +++ b/tests/hot_reload/existing_field_changes_type_indirect/main.0.dart @@ -30,7 +30,6 @@ Future main() async { await hotReload(); - Expect.contains( - "type 'B' is not a subtype of type 'A' of 'function result'", helper()); + Expect.contains("type 'B' is not a subtype of type 'A'", helper()); Expect.equals(1, hotReloadGeneration); } diff --git a/tests/hot_reload/existing_field_changes_type_indirect/main.1.dart b/tests/hot_reload/existing_field_changes_type_indirect/main.1.dart index f89a7ea8cdd..c8fcb3ca096 100644 --- a/tests/hot_reload/existing_field_changes_type_indirect/main.1.dart +++ b/tests/hot_reload/existing_field_changes_type_indirect/main.1.dart @@ -30,8 +30,7 @@ Future main() async { await hotReload(); - Expect.contains( - "type 'B' is not a subtype of type 'A' of 'function result'", helper()); + Expect.contains("type 'B' is not a subtype of type 'A'", helper()); Expect.equals(1, hotReloadGeneration); } /** DIFF **/ diff --git a/tests/hot_reload/existing_field_changes_type_indirect_function/main.0.dart b/tests/hot_reload/existing_field_changes_type_indirect_function/main.0.dart index b372ec8ebb9..ca9c35cc64d 100644 --- a/tests/hot_reload/existing_field_changes_type_indirect_function/main.0.dart +++ b/tests/hot_reload/existing_field_changes_type_indirect_function/main.0.dart @@ -34,8 +34,6 @@ Future main() async { // B is no longer a subtype of A. Expect.equals( - "type '(A) => bool' is not a subtype of type " - "'(B) => bool' of 'function result'", - helper()); + "type '(A) => bool' is not a subtype of type '(B) => bool'", helper()); Expect.equals(1, hotReloadGeneration); } diff --git a/tests/hot_reload/existing_field_changes_type_indirect_function/main.1.dart b/tests/hot_reload/existing_field_changes_type_indirect_function/main.1.dart index 07403f84c0e..d3250f854f3 100644 --- a/tests/hot_reload/existing_field_changes_type_indirect_function/main.1.dart +++ b/tests/hot_reload/existing_field_changes_type_indirect_function/main.1.dart @@ -37,9 +37,7 @@ Future main() async { // B is no longer a subtype of A. Expect.equals( - "type '(A) => bool' is not a subtype of type " - "'(B) => bool' of 'function result'", - helper()); + "type '(A) => bool' is not a subtype of type '(B) => bool'", helper()); Expect.equals(1, hotReloadGeneration); } /** DIFF **/ diff --git a/tests/hot_reload/existing_field_changes_type_indirect_generic/main.0.dart b/tests/hot_reload/existing_field_changes_type_indirect_generic/main.0.dart index 67b69bd3cdb..a1acd7ccf35 100644 --- a/tests/hot_reload/existing_field_changes_type_indirect_generic/main.0.dart +++ b/tests/hot_reload/existing_field_changes_type_indirect_generic/main.0.dart @@ -32,7 +32,6 @@ Future main() async { // B is no longer a subtype of A. Expect.contains( - "type 'List' is not a subtype of type 'List' of 'function result'", - helper()); + "type 'List' is not a subtype of type 'List'", helper()); Expect.equals(1, hotReloadGeneration); } diff --git a/tests/hot_reload/existing_field_changes_type_indirect_generic/main.1.dart b/tests/hot_reload/existing_field_changes_type_indirect_generic/main.1.dart index a74f66957f3..d0d98dcc652 100644 --- a/tests/hot_reload/existing_field_changes_type_indirect_generic/main.1.dart +++ b/tests/hot_reload/existing_field_changes_type_indirect_generic/main.1.dart @@ -35,8 +35,7 @@ Future main() async { // B is no longer a subtype of A. Expect.contains( - "type 'List' is not a subtype of type 'List' of 'function result'", - helper()); + "type 'List' is not a subtype of type 'List'", helper()); Expect.equals(1, hotReloadGeneration); } /** DIFF **/ diff --git a/tests/hot_reload/existing_static_field_changes_type/main.0.dart b/tests/hot_reload/existing_static_field_changes_type/main.0.dart index 3275cdb7971..8c89c6b0a24 100644 --- a/tests/hot_reload/existing_static_field_changes_type/main.0.dart +++ b/tests/hot_reload/existing_static_field_changes_type/main.0.dart @@ -30,7 +30,6 @@ Future main() async { await hotReload(); - Expect.contains( - "type 'A' is not a subtype of type 'B' of 'function result'", helper()); + Expect.contains("type 'A' is not a subtype of type 'B'", helper()); Expect.equals(1, hotReloadGeneration); } diff --git a/tests/hot_reload/existing_static_field_changes_type/main.1.dart b/tests/hot_reload/existing_static_field_changes_type/main.1.dart index b3548355ef5..049c0613522 100644 --- a/tests/hot_reload/existing_static_field_changes_type/main.1.dart +++ b/tests/hot_reload/existing_static_field_changes_type/main.1.dart @@ -30,8 +30,7 @@ Future main() async { await hotReload(); - Expect.contains( - "type 'A' is not a subtype of type 'B' of 'function result'", helper()); + Expect.contains("type 'A' is not a subtype of type 'B'", helper()); Expect.equals(1, hotReloadGeneration); } /** DIFF **/ diff --git a/tests/hot_reload/existing_static_field_changes_type_indirect/main.0.dart b/tests/hot_reload/existing_static_field_changes_type_indirect/main.0.dart index fa315f0afe2..86244eb989d 100644 --- a/tests/hot_reload/existing_static_field_changes_type_indirect/main.0.dart +++ b/tests/hot_reload/existing_static_field_changes_type_indirect/main.0.dart @@ -30,7 +30,6 @@ Future main() async { await hotReload(); - Expect.contains( - "type 'B' is not a subtype of type 'A' of 'function result'", helper()); + Expect.contains("type 'B' is not a subtype of type 'A'", helper()); Expect.equals(1, hotReloadGeneration); } diff --git a/tests/hot_reload/existing_static_field_changes_type_indirect/main.1.dart b/tests/hot_reload/existing_static_field_changes_type_indirect/main.1.dart index e5062fb9f03..d919ef01523 100644 --- a/tests/hot_reload/existing_static_field_changes_type_indirect/main.1.dart +++ b/tests/hot_reload/existing_static_field_changes_type_indirect/main.1.dart @@ -30,8 +30,7 @@ Future main() async { await hotReload(); - Expect.contains( - "type 'B' is not a subtype of type 'A' of 'function result'", helper()); + Expect.contains("type 'B' is not a subtype of type 'A'", helper()); Expect.equals(1, hotReloadGeneration); } /** DIFF **/ diff --git a/tests/hot_reload/existing_static_field_changes_type_indirect_function/config.json b/tests/hot_reload/existing_static_field_changes_type_indirect_function/config.json new file mode 100644 index 00000000000..b72fb4b01b6 --- /dev/null +++ b/tests/hot_reload/existing_static_field_changes_type_indirect_function/config.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} \ No newline at end of file diff --git a/tests/hot_reload/existing_static_field_changes_type_indirect_function/main.0.dart b/tests/hot_reload/existing_static_field_changes_type_indirect_function/main.0.dart new file mode 100644 index 00000000000..c44ed990451 --- /dev/null +++ b/tests/hot_reload/existing_static_field_changes_type_indirect_function/main.0.dart @@ -0,0 +1,36 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L5929 + +class A {} + +class B extends A {} + +typedef bool Predicate(B b); + +Predicate value = init(); +init() => (A a) => true; + +String helper() { + try { + return value.toString(); + } catch (e) { + return e.toString(); + } +} + +Future main() async { + Expect.contains('Closure: (A) => bool', helper()); + + await hotReload(); + + // B is no longer a subtype of A. + Expect.contains( + "type '(A) => bool' is not a subtype of type '(B) => bool'", helper()); +} diff --git a/tests/hot_reload/existing_static_field_changes_type_indirect_function/main.1.dart b/tests/hot_reload/existing_static_field_changes_type_indirect_function/main.1.dart new file mode 100644 index 00000000000..fce38d0b9d7 --- /dev/null +++ b/tests/hot_reload/existing_static_field_changes_type_indirect_function/main.1.dart @@ -0,0 +1,48 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L5929 + +class A {} + +class B {} + +typedef bool Predicate(B b); + +Predicate value = init(); +init() => (A a) => true; + +String helper() { + try { + return value.toString(); + } catch (e) { + return e.toString(); + } +} + +Future main() async { + Expect.contains('Closure: (A) => bool', helper()); + + await hotReload(); + + // B is no longer a subtype of A. + Expect.contains( + "type '(A) => bool' is not a subtype of type '(B) => bool'", helper()); +} +/** DIFF **/ +/* +@@ -10,7 +10,7 @@ + + class A {} + +-class B extends A {} ++class B {} + + typedef bool Predicate(B b); + +*/ diff --git a/tests/hot_reload/existing_static_field_changes_type_indirect_generic/config.json b/tests/hot_reload/existing_static_field_changes_type_indirect_generic/config.json new file mode 100644 index 00000000000..b72fb4b01b6 --- /dev/null +++ b/tests/hot_reload/existing_static_field_changes_type_indirect_generic/config.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} \ No newline at end of file diff --git a/tests/hot_reload/existing_static_field_changes_type_indirect_generic/main.0.dart b/tests/hot_reload/existing_static_field_changes_type_indirect_generic/main.0.dart new file mode 100644 index 00000000000..0952a012521 --- /dev/null +++ b/tests/hot_reload/existing_static_field_changes_type_indirect_generic/main.0.dart @@ -0,0 +1,34 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L5841 + +class A {} + +class B extends A {} + +List value = init(); +init() => List.empty(); + +String helper() { + try { + return value.toString(); + } catch (e) { + return e.toString(); + } +} + +Future main() async { + Expect.equals('[]', helper()); + + await hotReload(); + + // B is no longer a subtype of A. + Expect.contains( + "type 'List' is not a subtype of type 'List'", helper()); +} diff --git a/tests/hot_reload/existing_static_field_changes_type_indirect_generic/main.1.dart b/tests/hot_reload/existing_static_field_changes_type_indirect_generic/main.1.dart new file mode 100644 index 00000000000..539fd388f3a --- /dev/null +++ b/tests/hot_reload/existing_static_field_changes_type_indirect_generic/main.1.dart @@ -0,0 +1,46 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L5841 + +class A {} + +class B {} + +List value = init(); +init() => List.empty(); + +String helper() { + try { + return value.toString(); + } catch (e) { + return e.toString(); + } +} + +Future main() async { + Expect.equals('[]', helper()); + + await hotReload(); + + // B is no longer a subtype of A. + Expect.contains( + "type 'List' is not a subtype of type 'List'", helper()); +} +/** DIFF **/ +/* +@@ -10,7 +10,7 @@ + + class A {} + +-class B extends A {} ++class B {} + + List value = init(); + init() => List.empty(); +*/ diff --git a/tests/hot_reload/not_typedef_to_typedef/config.json b/tests/hot_reload/not_typedef_to_typedef/config.json new file mode 100644 index 00000000000..b72fb4b01b6 --- /dev/null +++ b/tests/hot_reload/not_typedef_to_typedef/config.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} \ No newline at end of file diff --git a/tests/hot_reload/not_typedef_to_typedef/main.0.dart b/tests/hot_reload/not_typedef_to_typedef/main.0.dart new file mode 100644 index 00000000000..34a341de2c6 --- /dev/null +++ b/tests/hot_reload/not_typedef_to_typedef/main.0.dart @@ -0,0 +1,30 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/680749e6559ecbc9166584ee34a20dbcda607e83/runtime/vm/isolate_reload_test.cc#L6039 + +// The CFE lowers typedefs to function types and as such the VM will not see +// any name collision between a class and a typedef class (which doesn't exist +// anymore). + +class Predicate { + bool call(dynamic x) { + return false; + } +} + +void expectHelper() { + Expect.notType((foo) => false); + Expect.notType(42); +} + +Future main() async { + expectHelper(); + await hotReload(); + expectHelper(); +} diff --git a/tests/hot_reload/not_typedef_to_typedef/main.1.dart b/tests/hot_reload/not_typedef_to_typedef/main.1.dart new file mode 100644 index 00000000000..dc277b5c77f --- /dev/null +++ b/tests/hot_reload/not_typedef_to_typedef/main.1.dart @@ -0,0 +1,46 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/680749e6559ecbc9166584ee34a20dbcda607e83/runtime/vm/isolate_reload_test.cc#L6039 + +// The CFE lowers typedefs to function types and as such the VM will not see +// any name collision between a class and a typedef class (which doesn't exist +// anymore). + +typedef bool Predicate(dynamic x); + +void expectHelper() { + Expect.type((foo) => false); + Expect.notType(42); +} + +Future main() async { + expectHelper(); + await hotReload(); + expectHelper(); +} +/** DIFF **/ +/* +@@ -12,14 +12,10 @@ + // any name collision between a class and a typedef class (which doesn't exist + // anymore). + +-class Predicate { +- bool call(dynamic x) { +- return false; +- } +-} ++typedef bool Predicate(dynamic x); + + void expectHelper() { +- Expect.notType((foo) => false); ++ Expect.type((foo) => false); + Expect.notType(42); + } + +*/ diff --git a/tests/hot_reload/run_new_field_initializers_cyclic_initialization/config.json b/tests/hot_reload/run_new_field_initializers_cyclic_initialization/config.json new file mode 100644 index 00000000000..b72fb4b01b6 --- /dev/null +++ b/tests/hot_reload/run_new_field_initializers_cyclic_initialization/config.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} \ No newline at end of file diff --git a/tests/hot_reload/run_new_field_initializers_cyclic_initialization/main.0.dart b/tests/hot_reload/run_new_field_initializers_cyclic_initialization/main.0.dart new file mode 100644 index 00000000000..6f7f735a9d7 --- /dev/null +++ b/tests/hot_reload/run_new_field_initializers_cyclic_initialization/main.0.dart @@ -0,0 +1,29 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/640ad1416eaa2779e33f19e11a3249bb4f9d13f9/runtime/vm/isolate_reload_test.cc#L5167 + +class Foo { + int x = 4; +} + +late Foo value; + +int helper() { + value = Foo(); + return value.x; +} + +Future main() async { + Expect.equals(4, helper()); + await hotReload(); + + // Verify that we ran field initializers on cyclic fields added to existing + // instances. + Expect.throws(() => helper()); +} diff --git a/tests/hot_reload/run_new_field_initializers_cyclic_initialization/main.1.dart b/tests/hot_reload/run_new_field_initializers_cyclic_initialization/main.1.dart new file mode 100644 index 00000000000..7951f0cf519 --- /dev/null +++ b/tests/hot_reload/run_new_field_initializers_cyclic_initialization/main.1.dart @@ -0,0 +1,48 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/640ad1416eaa2779e33f19e11a3249bb4f9d13f9/runtime/vm/isolate_reload_test.cc#L5167 + +class Foo { + int x = 4; + int y = value.y; +} + +late Foo value; + +int helper() { + return value.y; +} + +Future main() async { + Expect.equals(4, helper()); + await hotReload(); + + // Verify that we ran field initializers on cyclic fields added to existing + // instances. + Expect.throws(() => helper()); +} +/** DIFF **/ +/* +@@ -10,13 +10,13 @@ + + class Foo { + int x = 4; ++ int y = value.y; + } + + late Foo value; + + int helper() { +- value = Foo(); +- return value.x; ++ return value.y; + } + + Future main() async { +*/ diff --git a/tests/hot_reload/run_new_field_initializers_super_class/config.json b/tests/hot_reload/run_new_field_initializers_super_class/config.json new file mode 100644 index 00000000000..b72fb4b01b6 --- /dev/null +++ b/tests/hot_reload/run_new_field_initializers_super_class/config.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} \ No newline at end of file diff --git a/tests/hot_reload/run_new_field_initializers_super_class/main.0.dart b/tests/hot_reload/run_new_field_initializers_super_class/main.0.dart new file mode 100644 index 00000000000..668bbbc2b34 --- /dev/null +++ b/tests/hot_reload/run_new_field_initializers_super_class/main.0.dart @@ -0,0 +1,32 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/640ad1416eaa2779e33f19e11a3249bb4f9d13f9/runtime/vm/isolate_reload_test.cc#L5323 + +class Super { + static var foo = 'right'; +} + +class Foo extends Super { + static var foo = 'wrong'; +} + +late Foo value; +String helper() { + value = Foo(); + return 'okay'; +} + +Future main() async { + Expect.equals('right', Super.foo); + Expect.equals('wrong', Foo.foo); + Expect.equals('okay', helper()); + await hotReload(); + + Expect.equals('right', helper()); +} diff --git a/tests/hot_reload/run_new_field_initializers_super_class/main.1.dart b/tests/hot_reload/run_new_field_initializers_super_class/main.1.dart new file mode 100644 index 00000000000..9bb0631c75c --- /dev/null +++ b/tests/hot_reload/run_new_field_initializers_super_class/main.1.dart @@ -0,0 +1,53 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/640ad1416eaa2779e33f19e11a3249bb4f9d13f9/runtime/vm/isolate_reload_test.cc#L5323 + +class Super { + static var foo = 'right'; + var newField = foo; +} + +class Foo extends Super { + static var foo = 'wrong'; +} + +late Foo value; +String helper() { + return value.newField; +} + +Future main() async { + Expect.equals('right', Super.foo); + Expect.equals('wrong', Foo.foo); + Expect.equals('okay', helper()); + await hotReload(); + + Expect.equals('right', helper()); +} +/** DIFF **/ +/* +@@ -10,6 +10,7 @@ + + class Super { + static var foo = 'right'; ++ var newField = foo; + } + + class Foo extends Super { +@@ -18,8 +19,7 @@ + + late Foo value; + String helper() { +- value = Foo(); +- return 'okay'; ++ return value.newField; + } + + Future main() async { +*/ diff --git a/tests/hot_reload/run_new_field_initializers_throws/config.json b/tests/hot_reload/run_new_field_initializers_throws/config.json new file mode 100644 index 00000000000..b72fb4b01b6 --- /dev/null +++ b/tests/hot_reload/run_new_field_initializers_throws/config.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} \ No newline at end of file diff --git a/tests/hot_reload/run_new_field_initializers_throws/main.0.dart b/tests/hot_reload/run_new_field_initializers_throws/main.0.dart new file mode 100644 index 00000000000..67d349ceac9 --- /dev/null +++ b/tests/hot_reload/run_new_field_initializers_throws/main.0.dart @@ -0,0 +1,29 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/640ad1416eaa2779e33f19e11a3249bb4f9d13f9/runtime/vm/isolate_reload_test.cc#L5127 + +class Foo { + int x = 4; +} + +late Foo value; + +int helper() { + value = Foo(); + return value.x; +} + +Future main() async { + Expect.equals(4, helper()); + await hotReload(); + + // Verify that we ran field initializers on throwing fields added to existing + // instances. + Expect.throws(() => helper(), (e) => '$e' == 'field throws'); +} diff --git a/tests/hot_reload/run_new_field_initializers_throws/main.1.dart b/tests/hot_reload/run_new_field_initializers_throws/main.1.dart new file mode 100644 index 00000000000..08201e0df07 --- /dev/null +++ b/tests/hot_reload/run_new_field_initializers_throws/main.1.dart @@ -0,0 +1,48 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/640ad1416eaa2779e33f19e11a3249bb4f9d13f9/runtime/vm/isolate_reload_test.cc#L5127 + +class Foo { + int x = 4; + int y = throw 'field throws'; +} + +late Foo value; + +int helper() { + return value.y; +} + +Future main() async { + Expect.equals(4, helper()); + await hotReload(); + + // Verify that we ran field initializers on throwing fields added to existing + // instances. + Expect.throws(() => helper(), (e) => '$e' == 'field throws'); +} +/** DIFF **/ +/* +@@ -10,13 +10,13 @@ + + class Foo { + int x = 4; ++ int y = throw 'field throws'; + } + + late Foo value; + + int helper() { +- value = Foo(); +- return value.x; ++ return value.y; + } + + Future main() async { +*/ diff --git a/tests/hot_reload/run_new_field_initializers_with_generics/config.json b/tests/hot_reload/run_new_field_initializers_with_generics/config.json new file mode 100644 index 00000000000..b72fb4b01b6 --- /dev/null +++ b/tests/hot_reload/run_new_field_initializers_with_generics/config.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} \ No newline at end of file diff --git a/tests/hot_reload/run_new_field_initializers_with_generics/main.0.dart b/tests/hot_reload/run_new_field_initializers_with_generics/main.0.dart new file mode 100644 index 00000000000..c6b068a37f1 --- /dev/null +++ b/tests/hot_reload/run_new_field_initializers_with_generics/main.0.dart @@ -0,0 +1,38 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L5381 + +class Foo { + T? x; +} + +late Foo value1; +late Foo value2; + +(dynamic, dynamic) helper() { + value1 = Foo(); + value2 = Foo(); + return (value1.x, value2.x); +} + +Future main() async { + var (v1, v2) = helper(); + Expect.type(v1); + Expect.type(v2); + await hotReload(); + + (v1, v2) = helper(); + Expect.type>(v1); + Expect.type>(v2); + await hotReload(); + + (v1, v2) = helper(); + Expect.type>(v1); + Expect.type>(v2); +} diff --git a/tests/hot_reload/run_new_field_initializers_with_generics/main.1.dart b/tests/hot_reload/run_new_field_initializers_with_generics/main.1.dart new file mode 100644 index 00000000000..694721e93e0 --- /dev/null +++ b/tests/hot_reload/run_new_field_initializers_with_generics/main.1.dart @@ -0,0 +1,58 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L5381 + +class Foo { + T? x; + List y = List.empty(); +} + +late Foo value1; +late Foo value2; + +(dynamic, dynamic) helper() { + return (value1.y, value2.y); +} + +Future main() async { + var (v1, v2) = helper(); + Expect.type(v1); + Expect.type(v2); + await hotReload(); + + (v1, v2) = helper(); + Expect.type>(v1); + Expect.type>(v2); + await hotReload(); + + (v1, v2) = helper(); + Expect.type>(v1); + Expect.type>(v2); +} +/** DIFF **/ +/* +@@ -10,15 +10,14 @@ + + class Foo { + T? x; ++ List y = List.empty(); + } + + late Foo value1; + late Foo value2; + + (dynamic, dynamic) helper() { +- value1 = Foo(); +- value2 = Foo(); +- return (value1.x, value2.x); ++ return (value1.y, value2.y); + } + + Future main() async { +*/ diff --git a/tests/hot_reload/run_new_field_initializers_with_generics/main.2.dart b/tests/hot_reload/run_new_field_initializers_with_generics/main.2.dart new file mode 100644 index 00000000000..8cc0a331271 --- /dev/null +++ b/tests/hot_reload/run_new_field_initializers_with_generics/main.2.dart @@ -0,0 +1,57 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L5381 + +class Foo { + T? x; + List y = List.empty(); + dynamic z = {}; +} + +late Foo value1; +late Foo value2; + +(dynamic, dynamic) helper() { + return (value1.z, value2.z); +} + +Future main() async { + var (v1, v2) = helper(); + Expect.type(v1); + Expect.type(v2); + await hotReload(); + + (v1, v2) = helper(); + Expect.type>(v1); + Expect.type>(v2); + await hotReload(); + + (v1, v2) = helper(); + Expect.type>(v1); + Expect.type>(v2); +} +/** DIFF **/ +/* +@@ -11,13 +11,14 @@ + class Foo { + T? x; + List y = List.empty(); ++ dynamic z = {}; + } + + late Foo value1; + late Foo value2; + + (dynamic, dynamic) helper() { +- return (value1.y, value2.y); ++ return (value1.z, value2.z); + } + + Future main() async { +*/ diff --git a/tests/hot_reload/super_class_changed/config.json b/tests/hot_reload/super_class_changed/config.json new file mode 100644 index 00000000000..b72fb4b01b6 --- /dev/null +++ b/tests/hot_reload/super_class_changed/config.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} \ No newline at end of file diff --git a/tests/hot_reload/super_class_changed/main.0.dart b/tests/hot_reload/super_class_changed/main.0.dart new file mode 100644 index 00000000000..c401055fb1e --- /dev/null +++ b/tests/hot_reload/super_class_changed/main.0.dart @@ -0,0 +1,26 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L760 + +class A {} + +class B extends A {} + +expectHelper() { + Expect.type(A()); + Expect.type(B()); + Expect.notType(A()); + Expect.type(B()); +} + +Future main() async { + expectHelper(); + await hotReload(); + expectHelper(); +} diff --git a/tests/hot_reload/super_class_changed/main.1.dart b/tests/hot_reload/super_class_changed/main.1.dart new file mode 100644 index 00000000000..7ba596c97b0 --- /dev/null +++ b/tests/hot_reload/super_class_changed/main.1.dart @@ -0,0 +1,48 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L760 + +class B {} + +class A extends B {} + +expectHelper() { + Expect.type(A()); + Expect.notType(B()); + Expect.type(A()); + Expect.type(B()); +} + +Future main() async { + expectHelper(); + await hotReload(); + expectHelper(); +} +/** DIFF **/ +/* +@@ -8,14 +8,14 @@ + // Adapted from: + // https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L760 + +-class A {} ++class B {} + +-class B extends A {} ++class A extends B {} + + expectHelper() { + Expect.type(A()); +- Expect.type(B()); +- Expect.notType(A()); ++ Expect.notType(B()); ++ Expect.type(A()); + Expect.type(B()); + } + +*/ diff --git a/tests/hot_reload/super_getter_rebound_to_method/config.json b/tests/hot_reload/super_getter_rebound_to_method/config.json new file mode 100644 index 00000000000..b72fb4b01b6 --- /dev/null +++ b/tests/hot_reload/super_getter_rebound_to_method/config.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} \ No newline at end of file diff --git a/tests/hot_reload/super_getter_rebound_to_method/main.0.dart b/tests/hot_reload/super_getter_rebound_to_method/main.0.dart new file mode 100644 index 00000000000..134d8f3a2e8 --- /dev/null +++ b/tests/hot_reload/super_getter_rebound_to_method/main.0.dart @@ -0,0 +1,26 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L6114 + +class A { + get x => "a"; +} + +class B extends A { + f() async { + var old_x = super.x; + await hotReload(); + var new_x = super.x; + return "$old_x:$new_x"; + } +} + +Future main() async { + Expect.equals('a:b', await B().f()); +} diff --git a/tests/hot_reload/super_getter_rebound_to_method/main.1.dart b/tests/hot_reload/super_getter_rebound_to_method/main.1.dart new file mode 100644 index 00000000000..b4057dec4c4 --- /dev/null +++ b/tests/hot_reload/super_getter_rebound_to_method/main.1.dart @@ -0,0 +1,38 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L6114 + +class A { + get x => "b"; +} + +class B extends A { + f() async { + var old_x = super.x; + await hotReload(); + var new_x = super.x; + return "$old_x:$new_x"; + } +} + +Future main() async { + Expect.equals('a:b', await B().f()); +} +/** DIFF **/ +/* +@@ -9,7 +9,7 @@ + // https://github.com/dart-lang/sdk/blob/63622f03eeaf72983b2f4957fa84da8062693f00/runtime/vm/isolate_reload_test.cc#L6114 + + class A { +- get x => "a"; ++ get x => "b"; + } + + class B extends A { +*/ diff --git a/tests/hot_reload/type_identity/config.json b/tests/hot_reload/type_identity/config.json new file mode 100644 index 00000000000..b72fb4b01b6 --- /dev/null +++ b/tests/hot_reload/type_identity/config.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} \ No newline at end of file diff --git a/tests/hot_reload/type_identity/main.0.dart b/tests/hot_reload/type_identity/main.0.dart new file mode 100644 index 00000000000..86c8c346196 --- /dev/null +++ b/tests/hot_reload/type_identity/main.0.dart @@ -0,0 +1,21 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L822 + +class T {} + +getType() => T; + +Future main() async { + var oldType = getType(); + await hotReload(); + + var newType = getType(); + Expect.identical(oldType, newType); +} diff --git a/tests/hot_reload/type_identity/main.1.dart b/tests/hot_reload/type_identity/main.1.dart new file mode 100644 index 00000000000..5a26bedfc53 --- /dev/null +++ b/tests/hot_reload/type_identity/main.1.dart @@ -0,0 +1,40 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L822 + +class T extends Stopwatch {} + +getType() => T; + +Future main() async { + var oldType = getType(); + await hotReload(); + + var newType = getType(); + Expect.identical(oldType, 34); +} +/** DIFF **/ +/* +@@ -8,7 +8,7 @@ + // Adapted from: + // https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L822 + +-class T {} ++class T extends Stopwatch {} + + getType() => T; + +@@ -17,5 +17,5 @@ + await hotReload(); + + var newType = getType(); +- Expect.identical(oldType, newType); ++ Expect.identical(oldType, 34); + } +*/ diff --git a/tests/hot_reload/type_identity_generic/config.json b/tests/hot_reload/type_identity_generic/config.json new file mode 100644 index 00000000000..b72fb4b01b6 --- /dev/null +++ b/tests/hot_reload/type_identity_generic/config.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} \ No newline at end of file diff --git a/tests/hot_reload/type_identity_generic/main.0.dart b/tests/hot_reload/type_identity_generic/main.0.dart new file mode 100644 index 00000000000..fe99b653bb7 --- /dev/null +++ b/tests/hot_reload/type_identity_generic/main.0.dart @@ -0,0 +1,21 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L853 + +class T {} + +getType() => T().runtimeType; + +Future main() async { + var oldType = getType(); + await hotReload(); + + var newType = getType(); + Expect.identical(oldType, newType); +} diff --git a/tests/hot_reload/type_identity_generic/main.1.dart b/tests/hot_reload/type_identity_generic/main.1.dart new file mode 100644 index 00000000000..0f39bd40225 --- /dev/null +++ b/tests/hot_reload/type_identity_generic/main.1.dart @@ -0,0 +1,33 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L853 + +class T extends Stopwatch {} + +getType() => T().runtimeType; + +Future main() async { + var oldType = getType(); + await hotReload(); + + var newType = getType(); + Expect.identical(oldType, newType); +} +/** DIFF **/ +/* +@@ -8,7 +8,7 @@ + // Adapted from: + // https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L853 + +-class T {} ++class T extends Stopwatch {} + + getType() => T().runtimeType; + +*/ diff --git a/tests/hot_reload/type_identity_parameter/config.json b/tests/hot_reload/type_identity_parameter/config.json new file mode 100644 index 00000000000..b72fb4b01b6 --- /dev/null +++ b/tests/hot_reload/type_identity_parameter/config.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} \ No newline at end of file diff --git a/tests/hot_reload/type_identity_parameter/main.0.dart b/tests/hot_reload/type_identity_parameter/main.0.dart new file mode 100644 index 00000000000..2e72021fdfb --- /dev/null +++ b/tests/hot_reload/type_identity_parameter/main.0.dart @@ -0,0 +1,23 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L884 + +class T { + getTypeVar() => G; +} + +getType() => T().getTypeVar(); + +Future main() async { + var oldType = getType(); + await hotReload(); + + var newType = getType(); + Expect.identical(oldType, newType); +} diff --git a/tests/hot_reload/type_identity_parameter/main.1.dart b/tests/hot_reload/type_identity_parameter/main.1.dart new file mode 100644 index 00000000000..c4f2c39749d --- /dev/null +++ b/tests/hot_reload/type_identity_parameter/main.1.dart @@ -0,0 +1,35 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L884 + +class T extends Stopwatch { + getTypeVar() => G; +} + +getType() => T().getTypeVar(); + +Future main() async { + var oldType = getType(); + await hotReload(); + + var newType = getType(); + Expect.identical(oldType, newType); +} +/** DIFF **/ +/* +@@ -8,7 +8,7 @@ + // Adapted from: + // https://github.com/dart-lang/sdk/blob/bc58f69e532960a2f1d88f4b282869d6e2ad7cbe/runtime/vm/isolate_reload_test.cc#L884 + +-class T { ++class T extends Stopwatch { + getTypeVar() => G; + } + +*/ diff --git a/tests/hot_reload/typedef_add_parameter/config.json b/tests/hot_reload/typedef_add_parameter/config.json new file mode 100644 index 00000000000..b72fb4b01b6 --- /dev/null +++ b/tests/hot_reload/typedef_add_parameter/config.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} \ No newline at end of file diff --git a/tests/hot_reload/typedef_add_parameter/main.0.dart b/tests/hot_reload/typedef_add_parameter/main.0.dart new file mode 100644 index 00000000000..d622244163d --- /dev/null +++ b/tests/hot_reload/typedef_add_parameter/main.0.dart @@ -0,0 +1,22 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/0b221871890a3daf331799aba7409bf299a35cfb/runtime/vm/isolate_reload_test.cc#L6065 + +typedef bool Predicate(dynamic x); + +void expectHelper() { + bool foo(x) => true; + Expect.type(foo); +} + +Future main() async { + expectHelper(); + await hotReload(); + expectHelper(); +} diff --git a/tests/hot_reload/typedef_add_parameter/main.1.dart b/tests/hot_reload/typedef_add_parameter/main.1.dart new file mode 100644 index 00000000000..012bfd0574e --- /dev/null +++ b/tests/hot_reload/typedef_add_parameter/main.1.dart @@ -0,0 +1,39 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/0b221871890a3daf331799aba7409bf299a35cfb/runtime/vm/isolate_reload_test.cc#L6065 + +typedef bool Predicate(dynamic x, dynamic y); + +void expectHelper() { + bool foo(x) => true; + Expect.notType(foo); +} + +Future main() async { + expectHelper(); + await hotReload(); + expectHelper(); +} +/** DIFF **/ +/* +@@ -8,11 +8,11 @@ + // Adapted from: + // https://github.com/dart-lang/sdk/blob/0b221871890a3daf331799aba7409bf299a35cfb/runtime/vm/isolate_reload_test.cc#L6065 + +-typedef bool Predicate(dynamic x); ++typedef bool Predicate(dynamic x, dynamic y); + + void expectHelper() { + bool foo(x) => true; +- Expect.type(foo); ++ Expect.notType(foo); + } + + Future main() async { +*/ diff --git a/tests/hot_reload/typedef_to_not_typedef/config.json b/tests/hot_reload/typedef_to_not_typedef/config.json new file mode 100644 index 00000000000..b72fb4b01b6 --- /dev/null +++ b/tests/hot_reload/typedef_to_not_typedef/config.json @@ -0,0 +1,3 @@ +{ + "exclude": [] +} \ No newline at end of file diff --git a/tests/hot_reload/typedef_to_not_typedef/main.0.dart b/tests/hot_reload/typedef_to_not_typedef/main.0.dart new file mode 100644 index 00000000000..72884be20b4 --- /dev/null +++ b/tests/hot_reload/typedef_to_not_typedef/main.0.dart @@ -0,0 +1,26 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/0b221871890a3daf331799aba7409bf299a35cfb/runtime/vm/isolate_reload_test.cc#L6013 + +// The CFE lowers typedefs to function types and as such the VM will not see +// any name collision between a class and a typedef class (which doesn't exist +// anymore). + +typedef bool Predicate(dynamic x); + +void expectHelper() { + Expect.type((foo) => false); + Expect.notType(42); +} + +Future main() async { + expectHelper(); + await hotReload(); + expectHelper(); +} diff --git a/tests/hot_reload/typedef_to_not_typedef/main.1.dart b/tests/hot_reload/typedef_to_not_typedef/main.1.dart new file mode 100644 index 00000000000..066f784fe18 --- /dev/null +++ b/tests/hot_reload/typedef_to_not_typedef/main.1.dart @@ -0,0 +1,50 @@ +// Copyright (c) 2024, 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. + +import 'package:expect/expect.dart'; +import 'package:reload_test/reload_test_utils.dart'; + +// Adapted from: +// https://github.com/dart-lang/sdk/blob/0b221871890a3daf331799aba7409bf299a35cfb/runtime/vm/isolate_reload_test.cc#L6013 + +// The CFE lowers typedefs to function types and as such the VM will not see +// any name collision between a class and a typedef class (which doesn't exist +// anymore). + +class Predicate { + bool call(dynamic x) { + return false; + } +} + +void expectHelper() { + Expect.notType((foo) => false); + Expect.notType(42); +} + +Future main() async { + expectHelper(); + await hotReload(); + expectHelper(); +} +/** DIFF **/ +/* +@@ -12,10 +12,14 @@ + // any name collision between a class and a typedef class (which doesn't exist + // anymore). + +-typedef bool Predicate(dynamic x); ++class Predicate { ++ bool call(dynamic x) { ++ return false; ++ } ++} + + void expectHelper() { +- Expect.type((foo) => false); ++ Expect.notType((foo) => false); + Expect.notType(42); + } + +*/