mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Suggest functions returning void as tearoffs where a void returning function is expected
Closes: https://github.com/dart-lang/sdk/issues/23984 Change-Id: I8291687d962a5d2885e5fa811167ca7e12aedc1c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201286 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
c9e78967d3
commit
9556697681
2 changed files with 24 additions and 0 deletions
|
@ -9,12 +9,32 @@ import '../../../../completion_test_support.dart';
|
|||
|
||||
void main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(ArgumentListCompletionTest);
|
||||
defineReflectiveTests(ConstructorCompletionTest);
|
||||
defineReflectiveTests(ExtensionCompletionTest);
|
||||
defineReflectiveTests(PropertyAccessorCompletionTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class ArgumentListCompletionTest extends CompletionTestCase {
|
||||
Future<void> test_functionWithVoidReturnType() async {
|
||||
addTestFile('''
|
||||
void f(C c) {
|
||||
c.m(^);
|
||||
}
|
||||
|
||||
void g() {}
|
||||
|
||||
class C {
|
||||
void m(void Function() handler) {}
|
||||
}
|
||||
''');
|
||||
await getSuggestions();
|
||||
assertHasCompletion('g');
|
||||
}
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class ConstructorCompletionTest extends CompletionTestCase {
|
||||
Future<void> test_constructor_abstract() async {
|
||||
|
|
|
@ -308,6 +308,10 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor<void> {
|
|||
}
|
||||
if (0 <= index && index < parameters.length) {
|
||||
var param = parameters[index];
|
||||
var paramType = param.type;
|
||||
if (paramType is FunctionType && paramType.returnType.isVoid) {
|
||||
optype.includeVoidReturnSuggestions = true;
|
||||
}
|
||||
if (param.isNamed == true) {
|
||||
var context = _argumentListContext(node);
|
||||
optype.completionLocation = 'ArgumentList_${context}_named';
|
||||
|
|
Loading…
Reference in a new issue