diff --git a/pkg/analysis_server/lib/src/services/correction/util.dart b/pkg/analysis_server/lib/src/services/correction/util.dart index 920fc8f9762..24458676d1c 100644 --- a/pkg/analysis_server/lib/src/services/correction/util.dart +++ b/pkg/analysis_server/lib/src/services/correction/util.dart @@ -861,6 +861,10 @@ class CorrectionUtils { } } + if (type is VoidType) { + return 'void'; + } + throw StateError('(${type.runtimeType}) $type'); } diff --git a/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart b/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart index 4370af41098..12017561a69 100644 --- a/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart +++ b/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart @@ -762,7 +762,8 @@ class ExtractMethodRefactoringImpl extends RefactoringImpl } else if (_returnType == null) { variableType = null; if (_hasAwait) { - returnType = _getTypeCode(typeProvider.futureDynamicType); + var futureVoid = typeProvider.futureType2(typeProvider.voidType); + returnType = _getTypeCode(futureVoid); } else { returnType = 'void'; } diff --git a/pkg/analysis_server/test/services/refactoring/extract_method_test.dart b/pkg/analysis_server/test/services/refactoring/extract_method_test.dart index 487842f85ac..71155fe2f4f 100644 --- a/pkg/analysis_server/test/services/refactoring/extract_method_test.dart +++ b/pkg/analysis_server/test/services/refactoring/extract_method_test.dart @@ -2431,7 +2431,7 @@ main() async { // end } -Future res() async { +Future res() async { int v = await getValue(); print(v); }