diff --git a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart index b465c698fcef..34dc4bb7deae 100644 --- a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart +++ b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart @@ -971,7 +971,8 @@ class AssistProcessor { return; } ConstructorElement element = creation.staticElement; - if (element.name != 'fromIterable' || + if (element == null || + element.name != 'fromIterable' || element.enclosingElement != typeProvider.mapType.element) { _coverageMarker(); return; diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_to_for_element_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_to_for_element_test.dart index 597c353bcc66..0a536802ed02 100644 --- a/pkg/analysis_server/test/src/services/correction/assist/convert_to_for_element_test.dart +++ b/pkg/analysis_server/test/src/services/correction/assist/convert_to_for_element_test.dart @@ -187,4 +187,14 @@ f(Iterable i) { } '''); } + + test_undefinedConstructor() async { + verifyNoTestUnitErrors = false; + await resolveTestUnit(''' +f() { + return new Unde/*caret*/fined(); +} +'''); + await assertNoAssist(); + } }