Skip to content

Commit edceedf

Browse files
rmacnak-googlecommit-bot@chromium.org
authored andcommitted
[vm, reload] Allow any change to a class that hasn't yet been declaration loaded.
Change-Id: I3da7a2f156e4b2cb1a60597d66f4514c1563785c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115560 Reviewed-by: Alexander Markov <[email protected]> Reviewed-by: Régis Crelier <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 68ba13e commit edceedf

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

runtime/vm/isolate_reload.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,8 +1377,7 @@ static void RecordChanges(const GrowableObjectArray& changed_in_last_reload,
13771377
return;
13781378
}
13791379

1380-
ASSERT(new_cls.is_finalized() == old_cls.is_finalized());
1381-
if (!new_cls.is_finalized()) {
1380+
if (!old_cls.is_finalized()) {
13821381
if (new_cls.SourceFingerprint() == old_cls.SourceFingerprint()) {
13831382
return;
13841383
}
@@ -1387,6 +1386,7 @@ static void RecordChanges(const GrowableObjectArray& changed_in_last_reload,
13871386
changed_in_last_reload.Add(new_cls);
13881387
return;
13891388
}
1389+
ASSERT(new_cls.is_finalized());
13901390

13911391
Zone* zone = Thread::Current()->zone();
13921392
const Array& functions = Array::Handle(zone, new_cls.functions());

runtime/vm/isolate_reload_test.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,6 +2151,7 @@ TEST_CASE(IsolateReload_EnumToNotEnum) {
21512151
" final int zero = 0;\n"
21522152
"}\n"
21532153
"main() {\n"
2154+
" return new Fruit().zero.toString();\n"
21542155
"}\n";
21552156

21562157
Dart_Handle result = TestCase::ReloadTestScript(kReloadScript);
@@ -2163,12 +2164,12 @@ TEST_CASE(IsolateReload_NotEnumToEnum) {
21632164
" final int zero = 0;\n"
21642165
"}\n"
21652166
"main() {\n"
2166-
" return 'yes';\n"
2167+
" return new Fruit().zero.toString();\n"
21672168
"}\n";
21682169

21692170
Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
21702171
EXPECT_VALID(lib);
2171-
EXPECT_STREQ("yes", SimpleInvokeStr(lib, "main"));
2172+
EXPECT_STREQ("0", SimpleInvokeStr(lib, "main"));
21722173

21732174
const char* kReloadScript =
21742175
"enum Fruit {\n"

runtime/vm/object_reload.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,12 @@ void Class::CheckReload(const Class& replacement,
693693
IsolateReloadContext* context) const {
694694
ASSERT(IsolateReloadContext::IsSameClass(*this, replacement));
695695

696+
if (!is_declaration_loaded()) {
697+
// The old class hasn't been used in any meanfully way, so the VM is okay
698+
// with any change.
699+
return;
700+
}
701+
696702
// Ensure is_enum_class etc have been set.
697703
replacement.EnsureDeclarationLoaded();
698704

0 commit comments

Comments
 (0)