Fix a bug in the convert_into_expression_body fix

Change-Id: Ieed0452eb1ec89b294e6d567df758b533ac4062f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198680
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_expression_function_body.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_expression_function_body.dart
index ed84716e..ef03f62 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_expression_function_body.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_expression_function_body.dart
@@ -28,6 +28,10 @@
     if (body is! BlockFunctionBody || body.isGenerator) {
       return;
     }
+    var parent = body.parent;
+    if (parent is ConstructorDeclaration && parent.factoryKeyword == null) {
+      return;
+    }
     // prepare return statement
     List<Statement> statements = body.block.statements;
     if (statements.length != 1) {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_into_expression_body_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_into_expression_body_test.dart
index 6e8152d..739509b 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_into_expression_body_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_into_expression_body_test.dart
@@ -90,7 +90,7 @@
 ''');
   }
 
-  Future<void> test_constructor() async {
+  Future<void> test_constructor_factory() async {
     await resolveTestCode('''
 class A {
   A.named();
@@ -109,6 +109,19 @@
 ''');
   }
 
+  Future<void> test_constructor_generative() async {
+    await resolveTestCode('''
+class A {
+  int x;
+
+  A() {
+    x = 3;
+  }
+}
+''');
+    await assertNoAssistAt('A()');
+  }
+
   Future<void> test_function_onBlock() async {
     await resolveTestCode('''
 fff() {