Implement DotShorthandConstructorInvocationImpl support for argument list context.

Bug: https://github.com/dart-lang/sdk/issues/61843
Change-Id: I54118ea6599c30e36918dd3255f6c79b2f02280e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457801
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Fedor Shcheglov
2025-10-27 20:46:32 -07:00
committed by Commit Queue
parent f3db4017b0
commit 33fcfbf3ab
2 changed files with 17 additions and 0 deletions
@@ -1837,6 +1837,8 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor<void> {
var parent = node.parent;
if (parent is Annotation) {
return 'annotation';
} else if (parent is DotShorthandConstructorInvocation) {
return 'constructor';
} else if (parent is EnumConstantArguments) {
return 'enumConstantArguments';
} else if (parent is ExtensionOverride) {
@@ -1131,6 +1131,21 @@ void f() {
);
}
Future<void> test_dotShorthandConstructorInvocation_arguments() async {
addTestSource('''
class C {
C({int? i});
}
void f() {
C _ = .new(^);
},
''');
await assertOpType(
completionLocation: 'ArgumentList_constructor_named',
namedArgs: true,
);
}
Future<void> test_dotShorthandConstructorInvocation_noTarget() async {
addTestSource('''
class C {