From ff3a841e2dc18ebe27ff02eb7aa02debabe28d8d Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Fri, 5 Oct 2018 15:52:31 +0000 Subject: [PATCH] [vm] Assert that we are not trying to construct old(reloaded) class constructor. Construction of old class constructor is not possible since we didn't keep its fields, its structure. Change-Id: I1e2239c0aa1012737e94c8ba42b0fc07a732b61d Reviewed-on: https://dart-review.googlesource.com/c/77986 Reviewed-by: Ryan Macnak Reviewed-by: Alexander Markov Commit-Queue: Alexander Aprelev --- runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc index 38a9a181a18..04b0b580b90 100644 --- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc +++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc @@ -1555,6 +1555,13 @@ Fragment StreamingFlowGraphBuilder::BuildFunctionBody( // initializers will be visible inside the entire body of the constructor. // We should make a separate scope for them. if (constructor) { + // PatchClass with different kernel_data means we are building a constructor + // for some old class. That is not supported and should not be happening as + // old classes are gone after hot reload, we don't have reference to old + // class's fields. + ASSERT(!Object::Handle(dart_function.RawOwner()).IsPatchClass() || + (Library::Handle(Class::Handle(dart_function.Owner()).library()) + .kernel_data() == dart_function.KernelData())); body += BuildInitializers(Class::Handle(Z, dart_function.Owner())); }