File tree Expand file tree Collapse file tree 5 files changed +65
-2
lines changed
lib/src/services/correction/dart
test/src/services/correction/assist Expand file tree Collapse file tree 5 files changed +65
-2
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ class ConvertToExpressionFunctionBody extends CorrectionProducer {
2828 if (body is ! BlockFunctionBody || body.isGenerator) {
2929 return ;
3030 }
31+ var parent = body.parent;
32+ if (parent is ConstructorDeclaration && parent.factoryKeyword == null ) {
33+ return ;
34+ }
3135 // prepare return statement
3236 List <Statement > statements = body.block.statements;
3337 if (statements.length != 1 ) {
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ main() {
9090''' );
9191 }
9292
93- Future <void > test_constructor () async {
93+ Future <void > test_constructor_factory () async {
9494 await resolveTestCode ('''
9595class A {
9696 A.named();
@@ -109,6 +109,19 @@ class A {
109109''' );
110110 }
111111
112+ Future <void > test_constructor_generative () async {
113+ await resolveTestCode ('''
114+ class A {
115+ int x;
116+
117+ A() {
118+ x = 3;
119+ }
120+ }
121+ ''' );
122+ await assertNoAssistAt ('A()' );
123+ }
124+
112125 Future <void > test_function_onBlock () async {
113126 await resolveTestCode ('''
114127fff() {
Original file line number Diff line number Diff line change 1+ // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
2+ // for details. All rights reserved. Use of this source code is governed by a
3+ // BSD-style license that can be found in the LICENSE file.
4+
5+ class _InspectorOverlayLayer {
6+ String selection;
7+
8+ _InspectorOverlayLayer (this .selection) {
9+ bool inDebugMode = false ;
10+ assert (() {
11+ inDebugMode = true ;
12+ return true ;
13+ }());
14+ if (inDebugMode == false ) {
15+ throw Error ();
16+ }
17+ }
18+ }
19+
20+ main () {
21+ _InspectorOverlayLayer ('hello' );
22+ _InspectorOverlayLayer ('hello' );
23+ }
Original file line number Diff line number Diff line change 1+ // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
2+ // for details. All rights reserved. Use of this source code is governed by a
3+ // BSD-style license that can be found in the LICENSE file.
4+
5+ class _InspectorOverlayLayer {
6+ String selection;
7+
8+ _InspectorOverlayLayer (this .selection) {
9+ bool inDebugMode = false ;
10+ assert (() {
11+ inDebugMode = true ;
12+ return true ;
13+ }());
14+ if (inDebugMode == false ) {
15+ throw Error ();
16+ }
17+ }
18+ }
19+
20+ main () {
21+ _InspectorOverlayLayer ('hello' );
22+ _InspectorOverlayLayer ('hello' );
23+ }
Original file line number Diff line number Diff line change @@ -27,5 +27,5 @@ CHANNEL dev
2727MAJOR 2
2828MINOR 14
2929PATCH 0
30- PRERELEASE 91
30+ PRERELEASE 92
3131PRERELEASE_PATCH 0
You can’t perform that action at this time.
0 commit comments