Do not offer to bind a declaring parameter to a field
Closes https://github.com/dart-lang/sdk/issues/63540 Change-Id: I72f8f76878e5a058f58aca80b1543a1141a68b72 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/511100 Commit-Queue: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
b32e313620
commit
e171e636d5
@@ -44,6 +44,13 @@ class BindToField extends ResolvedCorrectionProducer {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (parameter.declaredFragment?.element
|
||||
case FieldFormalParameterElement element) {
|
||||
if (element.isDeclaring) {
|
||||
// A declaring parameter is already bound to a field.
|
||||
return;
|
||||
}
|
||||
}
|
||||
await tryReplacingParameter(file, builder, parameter, libraryElement2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,13 @@ class BindToFieldTest extends AssistProcessorTest {
|
||||
@override
|
||||
AssistKind get kind => DartAssistKind.bindToField;
|
||||
|
||||
Future<void> test_class_primaryConstructor_declaring() async {
|
||||
await resolveTestCode('''
|
||||
class C(final int ^i);
|
||||
''');
|
||||
await assertNoAssist();
|
||||
}
|
||||
|
||||
Future<void> test_class_primaryConstructor_requiredPositional() async {
|
||||
await resolveTestCode('''
|
||||
class C(int ^i);
|
||||
|
||||
Reference in New Issue
Block a user