Skip to content

Bad completion/recovery when typing before await #53964

@DanTup

Description

@DanTup

This seems similar to #49477 except it's with await instead of a nested function. The ASTs are a little different so I'm raising a new issue, but feel free to close if it seems like they're the same. It was raised at Dart-Code/Dart-Code#4825 by @JCKodel.

Future<void> main() async {
  a. // Trying to type a new line of code here before an `await`
  await a.mAsync();
}

final a = A();

class A {
  void m() {}
  Future<void> mAsync() async {}
}

You'd expect to see m() listed in the completion because it's valid to call here.

image

The AST has a.await joined together as a type:

┊   ┊   ┊   ┊   BlockImpl [26..56]
┊   ┊   ┊   ┊   ┊   VariableDeclarationStatementImpl [31..43]
┊   ┊   ┊   ┊   ┊   ┊   VariableDeclarationListImpl [31..43]
┊   ┊   ┊   ┊   ┊   ┊   ┊   NamedTypeImpl [31..41]
┊   ┊   ┊   ┊   ┊   ┊   ┊   ┊        name = a.await
┊   ┊   ┊   ┊   ┊   ┊   ┊   ┊        type = InvalidType
┊   ┊   ┊   ┊   ┊   ┊   ┊   ┊   ImportPrefixReferenceImpl [31..32]
┊   ┊   ┊   ┊   ┊   ┊   ┊   VariableDeclarationImpl [43..43]
┊   ┊   ┊   ┊   ┊   ┊   ┊   ┊        declaredElement = InvalidType a
┊   ┊   ┊   ┊   ┊   ┊   ┊   ┊        name = a
┊   ┊   ┊   ┊   ┊   ExpressionStatementImpl [44..53]
┊   ┊   ┊   ┊   ┊   ┊   MethodInvocationImpl [44..52]
┊   ┊   ┊   ┊   ┊   ┊   ┊        static invoke type = InvalidType
┊   ┊   ┊   ┊   ┊   ┊   ┊        static type = InvalidType
┊   ┊   ┊   ┊   ┊   ┊   ┊   SimpleIdentifierImpl [44..43] (synthetic)
┊   ┊   ┊   ┊   ┊   ┊   ┊   ┊        name =
┊   ┊   ┊   ┊   ┊   ┊   ┊   ┊        static type = InvalidType
┊   ┊   ┊   ┊   ┊   ┊   ┊   SimpleIdentifierImpl [45..50]
┊   ┊   ┊   ┊   ┊   ┊   ┊   ┊        name = mAsync
┊   ┊   ┊   ┊   ┊   ┊   ┊   ┊        static type = InvalidType
┊   ┊   ┊   ┊   ┊   ┊   ┊   ArgumentListImpl [51..52]

I'm not sure whether this is something completion should work around, or whether the AST could be improved.

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work ondevexp-completionIssues with the analysis server's code completion featuredevexp-completion-correctnessIssues with the correctness of the analysis server's code completion featurelegacy-area-analyzerUse area-devexp instead.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions