| Index: pkg/analyzer/lib/src/generated/resolver.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
|
| index 71d43478c8322932267836162830ababf09a55fc..1f4ead279a549c3379c254346290d83c0ecdf24b 100644
|
| --- a/pkg/analyzer/lib/src/generated/resolver.dart
|
| +++ b/pkg/analyzer/lib/src/generated/resolver.dart
|
| @@ -15651,6 +15651,25 @@ class _GatherUsedElementsVisitor extends RecursiveAstVisitor {
|
| }
|
|
|
| @override
|
| + visitFunctionDeclaration(FunctionDeclaration node) {
|
| + ExecutableElement enclosingExecOld = _enclosingExec;
|
| + try {
|
| + _enclosingExec = node.element;
|
| + super.visitFunctionDeclaration(node);
|
| + } finally {
|
| + _enclosingExec = enclosingExecOld;
|
| + }
|
| + }
|
| +
|
| + @override
|
| + visitFunctionExpression(FunctionExpression node) {
|
| + if (node.parent is! FunctionDeclaration) {
|
| + _useElement(node.element);
|
| + }
|
| + super.visitFunctionExpression(node);
|
| + }
|
| +
|
| + @override
|
| visitMethodDeclaration(MethodDeclaration node) {
|
| ExecutableElement enclosingExecOld = _enclosingExec;
|
| try {
|
| @@ -15807,7 +15826,7 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor {
|
|
|
| @override
|
| visitFieldElement(FieldElement element) {
|
| - if (!element.isSynthetic && !_isReadMember(element)) {
|
| + if (!_isReadMember(element)) {
|
| _reportErrorForElement(
|
| HintCode.UNUSED_FIELD,
|
| element,
|
| @@ -15817,6 +15836,17 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor {
|
| }
|
|
|
| @override
|
| + visitFunctionElement(FunctionElement element) {
|
| + if (!_isUsedElement(element)) {
|
| + _reportErrorForElement(
|
| + HintCode.UNUSED_ELEMENT,
|
| + element,
|
| + [element.kind.displayName, element.displayName]);
|
| + }
|
| + super.visitFunctionElement(element);
|
| + }
|
| +
|
| + @override
|
| visitLocalVariableElement(LocalVariableElement element) {
|
| if (!_isUsedElement(element)) {
|
| _reportErrorForElement(
|
| @@ -15839,7 +15869,7 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor {
|
|
|
| @override
|
| visitPropertyAccessorElement(PropertyAccessorElement element) {
|
| - if (!element.isSynthetic && !_isUsedMember(element)) {
|
| + if (!_isUsedMember(element)) {
|
| _reportErrorForElement(
|
| HintCode.UNUSED_ELEMENT,
|
| element,
|
| @@ -15849,7 +15879,13 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor {
|
| }
|
|
|
| bool _isUsedElement(Element element) {
|
| - if (element is! LocalVariableElement) {
|
| + if (element.isSynthetic) {
|
| + return true;
|
| + }
|
| + if (element is LocalVariableElement ||
|
| + element is FunctionElement && !element.isStatic) {
|
| + // local variable or function
|
| + } else {
|
| if (element.isPublic) {
|
| return true;
|
| }
|
| @@ -15861,6 +15897,9 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor {
|
| if (element.isPublic) {
|
| return true;
|
| }
|
| + if (element.isSynthetic) {
|
| + return true;
|
| + }
|
| return _usedElements.readMembers.contains(element.displayName);
|
| }
|
|
|
| @@ -15868,6 +15907,9 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor {
|
| if (element.isPublic) {
|
| return true;
|
| }
|
| + if (element.isSynthetic) {
|
| + return true;
|
| + }
|
| if (_usedElements.members.contains(element.displayName)) {
|
| return true;
|
| }
|
|
|