File tree Expand file tree Collapse file tree 3 files changed +28
-4
lines changed
lib/src/services/correction/dart
src/services/correction/fix Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ class ChangeTypeAnnotation extends CorrectionProducer {
2323
2424 @override
2525 Future <void > compute (DartChangeBuilder builder) async {
26- var declaration = coveredNode.parent;
26+ var declaration = coveredNode? .parent;
2727 if (declaration is VariableDeclaration &&
2828 declaration.initializer == coveredNode) {
2929 var variableList = declaration.parent;
Original file line number Diff line number Diff line change @@ -132,18 +132,29 @@ class AbstractContextTest with ResourceProviderMixin {
132132 }
133133
134134 /// Create an analysis options file based on the given arguments.
135- void createAnalysisOptionsFile (
136- {List <String > experiments, List <String > lints}) {
135+ void createAnalysisOptionsFile ({
136+ List <String > experiments,
137+ bool implicitCasts,
138+ List <String > lints,
139+ }) {
137140 var buffer = StringBuffer ();
138141
139- if (experiments != null ) {
142+ if (experiments != null || implicitCasts != null ) {
140143 buffer.writeln ('analyzer:' );
144+ }
145+
146+ if (experiments != null ) {
141147 buffer.writeln (' enable-experiment:' );
142148 for (var experiment in experiments) {
143149 buffer.writeln (' - $experiment ' );
144150 }
145151 }
146152
153+ if (implicitCasts != null ) {
154+ buffer.writeln (' strong-mode:' );
155+ buffer.writeln (' implicit-casts: $implicitCasts ' );
156+ }
157+
147158 if (lints != null ) {
148159 buffer.writeln ('linter:' );
149160 buffer.writeln (' rules:' );
Original file line number Diff line number Diff line change 33// BSD-style license that can be found in the LICENSE file.
44
55import 'package:analysis_server/src/services/correction/fix.dart' ;
6+ import 'package:analyzer/src/error/codes.dart' ;
67import 'package:analyzer_plugin/utilities/fixes/fixes.dart' ;
78import 'package:test_reflective_loader/test_reflective_loader.dart' ;
89
@@ -69,4 +70,16 @@ main() {
6970}
7071''' );
7172 }
73+
74+ Future <void > test_synthetic_implicitCast () async {
75+ createAnalysisOptionsFile (implicitCasts: false );
76+ await resolveTestUnit ('''
77+ int foo =
78+ ''' );
79+ await assertNoFix (
80+ errorFilter: (e) {
81+ return e.errorCode == StaticTypeWarningCode .INVALID_ASSIGNMENT ;
82+ },
83+ );
84+ }
7285}
You can’t perform that action at this time.
0 commit comments