Skip to content

Commit

Permalink
Fix failure when linting getters (issue 27545)
Browse files Browse the repository at this point in the history
R=pquitslund@google.com

Review URL: https://codereview.chromium.org//2403443003 .
  • Loading branch information
bwilkerson committed Oct 7, 2016
1 parent 4239523 commit aca9843
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 9 additions & 5 deletions lib/src/rules/parameter_assignments.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,14 @@ class _Visitor extends SimpleAstVisitor {

@override
void visitMethodDeclaration(MethodDeclaration node) {
node.parameters.parameters.forEach((e) {
if (node.body.isPotentiallyMutatedInScope(e.element)) {
rule.reportLint(e);
}
});
FormalParameterList parameterList = node.parameters;
if (parameterList != null) {
// Getters don't have parameters.
parameterList.parameters.forEach((e) {
if (node.body.isPotentiallyMutatedInScope(e.element)) {
rule.reportLint(e);
}
});
}
}
}
8 changes: 7 additions & 1 deletion test/rules/parameter_assignments.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ void ok(String parameter) {
}

class A {
void badFunction(int parameter) { // LINT
int get x => 0;

set x(int value) { // LINT
value = 5;
}

void badFunction(int parameter) { // LINT
parameter = 4;
}

Expand Down

0 comments on commit aca9843

Please sign in to comment.