Merge pull request #969 from dart-lang/966-duplicate-if-comment

Don't duplicate comments on chained if elements.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a5f41bd..a51736f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 1.3.9
+
+* Don't duplicate comments on chained if elements (#966).
+
 # 1.3.8
 
 * Preserve `?` in initializing formal function-typed parameters (#960).
diff --git a/lib/src/cli/formatter_options.dart b/lib/src/cli/formatter_options.dart
index 509eafb..75c67db 100644
--- a/lib/src/cli/formatter_options.dart
+++ b/lib/src/cli/formatter_options.dart
@@ -13,7 +13,7 @@
 import 'summary.dart';
 
 // Note: The following line of code is modified by tool/grind.dart.
-const dartStyleVersion = '1.3.8+1';
+const dartStyleVersion = '1.3.9';
 
 /// Global options that affect how the formatter produces and uses its outputs.
 class FormatterOptions {
diff --git a/lib/src/source_visitor.dart b/lib/src/source_visitor.dart
index 1fbdaca..6a54395 100644
--- a/lib/src/source_visitor.dart
+++ b/lib/src/source_visitor.dart
@@ -1931,7 +1931,7 @@
           split();
         }
 
-        token(node.elseKeyword);
+        token(element.elseKeyword);
 
         // If there is another if element in the chain, put a space between
         // it and this "else".
diff --git a/pubspec.yaml b/pubspec.yaml
index 08c1843..5221cc3 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
 name: dart_style
 # Note: See tool/grind.dart for how to bump the version.
-version: 1.3.8+1
+version: 1.3.9
 description: >-
   Opinionated, automatic Dart source code formatter.
   Provides an API and a CLI tool.
diff --git a/test/regression/0900/0966.stmt b/test/regression/0900/0966.stmt
new file mode 100644
index 0000000..e8add96
--- /dev/null
+++ b/test/regression/0900/0966.stmt
@@ -0,0 +1,24 @@
+>>>
+return [
+      for (final x in exampleList)
+        if (conditionA)
+          ItemConstructorA()
+       // Sample multi-line comment
+      // which broke the formatter
+        else if (conditionB)
+           ItemConstructorB()
+     else
+       ItemConstructorC()
+];
+<<<
+return [
+  for (final x in exampleList)
+    if (conditionA)
+      ItemConstructorA()
+    // Sample multi-line comment
+    // which broke the formatter
+    else if (conditionB)
+      ItemConstructorB()
+    else
+      ItemConstructorC()
+];
\ No newline at end of file