mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 11:03:19 +00:00
Issue 48184. Fix suggesting local function returning void in named argument.
Bug: https://github.com/dart-lang/sdk/issues/48184 Change-Id: I5f6c8f2443782dec3c75c44cb7baeea8ed8b5e0c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229282 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
8781ab0151
commit
47eff41cdb
|
@ -184,6 +184,11 @@ extension CompletionSuggestionExtension
|
|||
element.isNotNull.kind.isField;
|
||||
}
|
||||
|
||||
void get isFunctionReference {
|
||||
kind.isIdentifier;
|
||||
element.isNotNull.kind.isFunction;
|
||||
}
|
||||
|
||||
void get isGetter {
|
||||
kind.isIdentifier;
|
||||
element.isNotNull.kind.isGetter;
|
||||
|
@ -380,6 +385,10 @@ extension ElementKindExtension on CheckTarget<ElementKind> {
|
|||
isEqualTo(ElementKind.FIELD);
|
||||
}
|
||||
|
||||
void get isFunction {
|
||||
isEqualTo(ElementKind.FUNCTION);
|
||||
}
|
||||
|
||||
void get isGetter {
|
||||
isEqualTo(ElementKind.GETTER);
|
||||
}
|
||||
|
|
|
@ -5102,6 +5102,28 @@ mixin foo on Object {
|
|||
assertSuggestLocalVariable('foo', 'int');
|
||||
}
|
||||
|
||||
Future<void>
|
||||
test_namedArgument_instanceCreation_x_localFunction_void() async {
|
||||
addTestSource('''
|
||||
class A {
|
||||
A({required void Function() a});
|
||||
}
|
||||
|
||||
class B {
|
||||
void bar() {
|
||||
void foo01() {}
|
||||
A(a: foo0^);
|
||||
}
|
||||
}
|
||||
''');
|
||||
await computeSuggestions();
|
||||
assertSuggestFunction(
|
||||
'foo01',
|
||||
'void',
|
||||
kind: CompletionSuggestionKind.IDENTIFIER,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> test_new_instance() async {
|
||||
addTestSource('import "dart:math"; class A {x() {new Random().^}}');
|
||||
await computeSuggestions();
|
||||
|
|
|
@ -956,6 +956,8 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor<void> {
|
|||
Element? element;
|
||||
if (grandparent is ConstructorReferenceNode) {
|
||||
element = grandparent.staticElement;
|
||||
} else if (grandparent is InstanceCreationExpression) {
|
||||
element = grandparent.constructorName.staticElement;
|
||||
} else if (grandparent is MethodInvocation) {
|
||||
element = grandparent.methodName.staticElement;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue