[vm/kernel/bytecode] Fix field initializers in constructors

Fix for failing test language_2/final_field_initialization_order_test.
Bytecode generator was incorrectly omitting field initializer if
constructor also has initializer for that field.

Change-Id: I046231865677e1e59122d4d61b238e52b88003b7
Reviewed-on: https://dart-review.googlesource.com/70140
Reviewed-by: RĂ©gis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
diff --git a/pkg/vm/lib/bytecode/gen_bytecode.dart b/pkg/vm/lib/bytecode/gen_bytecode.dart
index 7ff51d4..1c543f5 100644
--- a/pkg/vm/lib/bytecode/gen_bytecode.dart
+++ b/pkg/vm/lib/bytecode/gen_bytecode.dart
@@ -260,10 +260,7 @@
         node.initializers.any((init) => init is RedirectingInitializer);
     if (!isRedirecting) {
       for (var field in node.enclosingClass.fields) {
-        if (!field.isStatic &&
-            field.initializer != null &&
-            !node.initializers.any(
-                (init) => init is FieldInitializer && init.field == field)) {
+        if (!field.isStatic && field.initializer != null) {
           _genFieldInitializer(field, field.initializer);
         }
       }
diff --git a/pkg/vm/testcases/bytecode/field_initializers.dart.expect b/pkg/vm/testcases/bytecode/field_initializers.dart.expect
index 1522863..5e795aa 100644
--- a/pkg/vm/testcases/bytecode/field_initializers.dart.expect
+++ b/pkg/vm/testcases/bytecode/field_initializers.dart.expect
@@ -16,30 +16,34 @@
   PushConstant         CP#0
   StoreFieldTOS        CP#1
   Push                 FP[-6]
-  Push                 FP[-5]
-  StoreFieldTOS        CP#3
+  PushConstant         CP#3
+  StoreFieldTOS        CP#4
   Push                 FP[-6]
-  PushConstant         CP#5
+  Push                 FP[-5]
   StoreFieldTOS        CP#6
   Push                 FP[-6]
-  PushConstant         CP#9
-  IndirectStaticCall   1, CP#8
-  Drop1
+  PushConstant         CP#8
+  StoreFieldTOS        CP#4
+  Push                 FP[-6]
   PushConstant         CP#10
+  IndirectStaticCall   1, CP#9
+  Drop1
+  PushConstant         CP#11
   ReturnTOS
 }
 ConstantPool {
   [0] = Int 42
   [1] = InstanceField #lib::A::foo3
   [2] = Reserved
-  [3] = InstanceField #lib::A::foo4
-  [4] = Reserved
-  [5] = Int 44
-  [6] = InstanceField #lib::A::foo5
+  [3] = Int 43
+  [4] = InstanceField #lib::A::foo5
+  [5] = Reserved
+  [6] = InstanceField #lib::A::foo4
   [7] = Reserved
-  [8] = ArgDesc num-args 1, num-type-args 0, names []
-  [9] = StaticICData target 'dart.core::Object::', arg-desc CP#8
-  [10] = Null
+  [8] = Int 44
+  [9] = ArgDesc num-args 1, num-type-args 0, names []
+  [10] = StaticICData target 'dart.core::Object::', arg-desc CP#9
+  [11] = Null
 }
 ]  constructor •(core::int foo4) → void
     : self::A::foo1 = null, self::A::foo4 = foo4, self::A::foo5 = 44, super core::Object::•()
@@ -52,34 +56,38 @@
   PushConstant         CP#0
   StoreFieldTOS        CP#1
   Push                 FP[-7]
+  PushConstant         CP#3
+  StoreFieldTOS        CP#4
+  Push                 FP[-7]
   Push                 FP[-6]
-  StoreFieldTOS        CP#3
+  StoreFieldTOS        CP#6
   Push                 FP[-7]
   Push                 FP[-5]
-  PushConstant         CP#5
-  InstanceCall         2, CP#7
-  StoreFieldTOS        CP#8
+  PushConstant         CP#8
+  InstanceCall         2, CP#10
+  StoreFieldTOS        CP#4
   Push                 FP[-7]
-  PushConstant         CP#11
-  IndirectStaticCall   1, CP#10
-  Drop1
   PushConstant         CP#12
+  IndirectStaticCall   1, CP#11
+  Drop1
+  PushConstant         CP#13
   ReturnTOS
 }
 ConstantPool {
   [0] = Int 42
   [1] = InstanceField #lib::A::foo3
   [2] = Reserved
-  [3] = InstanceField #lib::A::foo1
-  [4] = Reserved
-  [5] = Int 1
-  [6] = ArgDesc num-args 2, num-type-args 0, names []
-  [7] = ICData target-name '+', arg-desc CP#6
-  [8] = InstanceField #lib::A::foo5
-  [9] = Reserved
-  [10] = ArgDesc num-args 1, num-type-args 0, names []
-  [11] = StaticICData target 'dart.core::Object::', arg-desc CP#10
-  [12] = Null
+  [3] = Int 43
+  [4] = InstanceField #lib::A::foo5
+  [5] = Reserved
+  [6] = InstanceField #lib::A::foo1
+  [7] = Reserved
+  [8] = Int 1
+  [9] = ArgDesc num-args 2, num-type-args 0, names []
+  [10] = ICData target-name '+', arg-desc CP#9
+  [11] = ArgDesc num-args 1, num-type-args 0, names []
+  [12] = StaticICData target 'dart.core::Object::', arg-desc CP#11
+  [13] = Null
 }
 ]  constructor constr2(core::int x, core::int y) → void
     : self::A::foo4 = null, self::A::foo1 = x, self::A::foo5 = y.{core::num::+}(1), super core::Object::•()
@@ -170,23 +178,27 @@
   PushConstant         CP#0
   StoreFieldTOS        CP#1
   Push                 FP[-7]
+  PushConstant         CP#3
+  StoreFieldTOS        CP#1
+  Push                 FP[-7]
   Push                 FP[-6]
   Push                 FP[-5]
-  PushConstant         CP#3
-  PushConstant         CP#5
-  IndirectStaticCall   4, CP#4
-  Drop1
+  PushConstant         CP#4
   PushConstant         CP#6
+  IndirectStaticCall   4, CP#5
+  Drop1
+  PushConstant         CP#7
   ReturnTOS
 }
 ConstantPool {
-  [0] = Int 50
+  [0] = Int 46
   [1] = InstanceField #lib::B::foo6
   [2] = Reserved
-  [3] = Int 51
-  [4] = ArgDesc num-args 4, num-type-args 0, names []
-  [5] = StaticICData target '#lib::A::redirecting2', arg-desc CP#4
-  [6] = Null
+  [3] = Int 50
+  [4] = Int 51
+  [5] = ArgDesc num-args 4, num-type-args 0, names []
+  [6] = StaticICData target '#lib::A::redirecting2', arg-desc CP#5
+  [7] = Null
 }
 ]  constructor c2(core::int i, core::int j) → void
     : self::B::foo6 = 50, super self::A::redirecting2(i, j, 51)