Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1569)

Unified Diff: runtime/vm/object.cc

Issue 10368004: Properly set the element type of literal lists. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 7305)
+++ runtime/vm/object.cc (working copy)
@@ -2447,12 +2447,11 @@
if (raw() == other.raw()) {
return true;
}
- if (IsMalformed() || !other.IsType() || other.IsMalformed()) {
+ if (IsMalformed() || other.IsMalformed() ||
+ (!other.IsType() && !other.IsInstantiatedType())) {
return false;
}
- Type& other_type = Type::Handle();
- other_type ^= other.raw();
- if (type_class() != other_type.type_class()) {
+ if (type_class() != other.type_class()) {
return false;
}
return AbstractTypeArguments::AreEqual(
@@ -2787,6 +2786,24 @@
}
+bool InstantiatedType::Equals(const AbstractType& other) const {
+ ASSERT(IsFinalized() && other.IsFinalized());
+ if (raw() == other.raw()) {
+ return true;
+ }
+ if (IsMalformed() || other.IsMalformed() ||
+ (!other.IsType() && !other.IsInstantiatedType())) {
+ return false;
+ }
+ if (type_class() != other.type_class()) {
+ return false;
+ }
+ return AbstractTypeArguments::AreEqual(
+ AbstractTypeArguments::Handle(arguments()),
+ AbstractTypeArguments::Handle(other.arguments()));
+}
+
+
const char* InstantiatedType::ToCString() const {
return "InstantiatedType";
}
@@ -8711,10 +8728,15 @@
RawArray* Array::Grow(const Array& source, int new_length, Heap::Space space) {
- intptr_t len = source.IsNull() ? 0 : source.Length();
+ const Array& result = Array::Handle(Array::New(new_length, space));
+ intptr_t len = 0;
+ if (!source.IsNull()) {
+ len = source.Length();
+ result.SetTypeArguments(
+ AbstractTypeArguments::Handle(source.GetTypeArguments()));
+ }
ASSERT(new_length >= len); // Cannot copy 'source' into new array.
ASSERT(new_length != len); // Unnecessary copying of array.
- const Array& result = Array::Handle(Array::New(new_length, space));
Object& obj = Object::Handle();
for (int i = 0; i < len; i++) {
obj = source.At(i);
@@ -8831,6 +8853,9 @@
const Array& new_contents =
Array::Handle(Array::Grow(contents, new_capacity, space));
StorePointer(&(raw_ptr()->data_), new_contents.raw());
+ ASSERT(AbstractTypeArguments::AreEqual(
+ AbstractTypeArguments::Handle(new_contents.GetTypeArguments()),
+ AbstractTypeArguments::Handle(raw_ptr()->type_arguments_)));
}

Powered by Google App Engine
This is Rietveld 408576698