Index: runtime/vm/object_reload.cc |
diff --git a/runtime/vm/object_reload.cc b/runtime/vm/object_reload.cc |
index 181ff495e616e4087b71dd8f6b0aaa9bd354ee87..cd065f7d1fe6bfd0bf4a786d7ef196be91e8fd2a 100644 |
--- a/runtime/vm/object_reload.cc |
+++ b/runtime/vm/object_reload.cc |
@@ -436,6 +436,21 @@ class EnumClassConflict : public ClassReasonForCancelling { |
}; |
+class TypedefClassConflict : public ClassReasonForCancelling { |
+ public: |
+ TypedefClassConflict(Zone* zone, const Class& from, const Class& to) |
+ : ClassReasonForCancelling(zone, from, to) {} |
+ |
+ RawString* ToString() { |
+ return String::NewFormatted( |
+ from_.IsTypedefClass() |
+ ? "Typedef class cannot be redefined to be a non-typedef class: %s" |
+ : "Class cannot be redefined to be a typedef class: %s", |
+ from_.ToCString()); |
+ } |
+}; |
+ |
+ |
class EnsureFinalizedError : public ClassReasonForCancelling { |
public: |
EnsureFinalizedError(Zone* zone, |
@@ -555,6 +570,13 @@ void Class::CheckReload(const Class& replacement, |
return; |
} |
+ // Class cannot change typedef property. |
+ if (IsTypedefClass() != replacement.IsTypedefClass()) { |
+ context->AddReasonForCancelling(new (context->zone()) TypedefClassConflict( |
+ context->zone(), *this, replacement)); |
+ return; |
+ } |
+ |
if (is_finalized()) { |
// Ensure the replacement class is also finalized. |
const Error& error = |