Update the strict-top-level-inference lint for primary constructors
Closes https://github.com/dart-lang/sdk/issues/61993 Change-Id: Ic0154898d5df87573d1b45a9de4c69795008fe52 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491704 Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
committed by
Commit Queue
parent
cb79275335
commit
8cf2e69e7a
@@ -41,6 +41,7 @@ class StrictTopLevelInference extends MultiAnalysisRule {
|
||||
registry.addConstructorDeclaration(this, visitor);
|
||||
registry.addFunctionDeclaration(this, visitor);
|
||||
registry.addMethodDeclaration(this, visitor);
|
||||
registry.addPrimaryConstructorDeclaration(this, visitor);
|
||||
registry.addVariableDeclarationList(this, visitor);
|
||||
}
|
||||
}
|
||||
@@ -92,6 +93,11 @@ class _Visitor extends SimpleAstVisitor<void> {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void visitPrimaryConstructorDeclaration(PrimaryConstructorDeclaration node) {
|
||||
_checkFormalParameters(node.formalParameters.parameters);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitVariableDeclarationList(VariableDeclarationList node) {
|
||||
if (node.type != null) return;
|
||||
|
||||
@@ -690,6 +690,48 @@ void f() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_primaryConstructorParameter_named_declaring_final() async {
|
||||
await assertDiagnosticsFromMarkdown(r'''
|
||||
class C({final [!p1!]});
|
||||
''');
|
||||
}
|
||||
|
||||
test_primaryConstructorParameter_named_declaring_typed() async {
|
||||
await assertNoDiagnostics(r'''
|
||||
class C({required int p1});
|
||||
''');
|
||||
}
|
||||
|
||||
test_primaryConstructorParameter_named_declaring_var() async {
|
||||
await assertDiagnosticsFromMarkdown(r'''
|
||||
class C({var [!p1!]});
|
||||
''');
|
||||
}
|
||||
|
||||
test_primaryConstructorParameter_positional() async {
|
||||
await assertDiagnosticsFromMarkdown(r'''
|
||||
class C([!p1!]);
|
||||
''');
|
||||
}
|
||||
|
||||
test_primaryConstructorParameter_positional_declaring_final() async {
|
||||
await assertDiagnosticsFromMarkdown(r'''
|
||||
class C(final [!p1!]);
|
||||
''');
|
||||
}
|
||||
|
||||
test_primaryConstructorParameter_positional_declaring_var() async {
|
||||
await assertDiagnosticsFromMarkdown(r'''
|
||||
class C(var [!p1!]);
|
||||
''');
|
||||
}
|
||||
|
||||
test_primaryConstructorParameter_positional_typed() async {
|
||||
await assertNoDiagnostics(r'''
|
||||
class C(int p1);
|
||||
''');
|
||||
}
|
||||
|
||||
test_reflectiveTest_nonTest() async {
|
||||
await assertDiagnostics(
|
||||
r'''
|
||||
|
||||
Reference in New Issue
Block a user