Version 1.4.0-dev.6.9

svn merge -c 36307 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
svn merge -c 36339 https://dart.googlecode.com/svn/branches/bleeding_edge trunk

git-svn-id: http://dart.googlecode.com/svn/trunk@36341 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 3fd21df..76110c1 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -3269,12 +3269,19 @@
     RETURN_TYPE_ERROR(isolate, type, Type);
   }
   const Class& cls = Class::Handle(isolate, type_obj.type_class());
+  const Error& error = Error::Handle(isolate, cls.EnsureIsFinalized(isolate));
+  if (!error.IsNull()) {
+    // An error occurred, return error object.
+    return Api::NewHandle(isolate, error.raw());
+  }
+
   if (!cls.is_fields_marked_nullable()) {
     // Mark all fields as nullable.
     Class& iterate_cls = Class::Handle(isolate, cls.raw());
     Field& field = Field::Handle(isolate);
     Array& fields = Array::Handle(isolate);
     while (!iterate_cls.IsNull()) {
+      ASSERT(iterate_cls.is_finalized());
       iterate_cls.set_is_fields_marked_nullable();
       fields = iterate_cls.fields();
       iterate_cls = iterate_cls.SuperClass();
@@ -3288,11 +3295,6 @@
     }
   }
 
-  const Error& error = Error::Handle(isolate, cls.EnsureIsFinalized(isolate));
-  if (!error.IsNull()) {
-    // An error occurred, return error object.
-    return Api::NewHandle(isolate, error.raw());
-  }
   // Allocate an object for the given class.
   return Api::NewHandle(isolate, Instance::New(cls));
 }
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index eacee90..5c4b9e1 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -13893,11 +13893,11 @@
       isolate, other_type.arguments());
   if (type_args.IsNull()) {
     // Ignore from_index.
-    return other_type_args.IsRaw(0, num_type_params);
+    return other_type_args.IsRaw(0, num_type_args);
   }
   if (other_type_args.IsNull()) {
     // Ignore from_index.
-    return type_args.IsRaw(0, num_type_params);
+    return type_args.IsRaw(0, num_type_args);
   }
   if (!type_args.IsSubvectorEquivalent(other_type_args,
                                        from_index,
diff --git a/tests/language/regress_18865_test.dart b/tests/language/regress_18865_test.dart
new file mode 100644
index 0000000..26ab350
--- /dev/null
+++ b/tests/language/regress_18865_test.dart
@@ -0,0 +1,15 @@
+// Copyright (c) 2014, 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.
+
+// Regression test for issue 18865.
+
+class B<T> { }
+
+class A<T> extends B {
+  static foo() => new A();
+}
+
+main () {
+    A.foo();
+}
diff --git a/tools/VERSION b/tools/VERSION
index 67d04a5..16152da 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -28,4 +28,4 @@
 MINOR 4
 PATCH 0
 PRERELEASE 6
-PRERELEASE_PATCH 8
+PRERELEASE_PATCH 9