Deprecate SimpleIdentifier.auxiliaryElements

Change-Id: Ie1e92cc61b7018d503cdf44c37611ea55b4b5391
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164760
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index 0811da9..50be3ba 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.40.4-dev
+* Deprecated `IndexExpression.auxiliaryElements` and
+  `SimpleIdentifier.auxiliaryElements`. Use `CompoundAssignmentExpression`.
+
 ## 0.40.3
 * Updated the current language version to `2.11`.
 * Bug fixes: 43541, 27896, 28066, 28066, 43497, 43478, 28066, 43465,
diff --git a/pkg/analyzer/lib/dart/ast/ast.dart b/pkg/analyzer/lib/dart/ast/ast.dart
index baa98f9..aa20e8b 100644
--- a/pkg/analyzer/lib/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/dart/ast/ast.dart
@@ -4603,11 +4603,15 @@
   /// The auxiliary elements hold the static and propagated elements associated
   /// with the getter context.
   // TODO(brianwilkerson) Replace this API.
+  @Deprecated('Use CompoundAssignmentExpression.readElement and/or '
+      'CompoundAssignmentExpression.writeElement')
   AuxiliaryElements get auxiliaryElements;
 
   /// Set the auxiliary elements associated with this identifier to the given
   /// [elements].
   // TODO(brianwilkerson) Replace this API.
+  @Deprecated('Use CompoundAssignmentExpression.readElement and/or '
+      'CompoundAssignmentExpression.writeElement')
   set auxiliaryElements(AuxiliaryElements elements);
 
   /// Return `true` if this identifier is the "name" part of a prefixed
diff --git a/pkg/analyzer/lib/src/dart/ast/ast.dart b/pkg/analyzer/lib/src/dart/ast/ast.dart
index 3a7cf4b..8fe624b 100644
--- a/pkg/analyzer/lib/src/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/src/dart/ast/ast.dart
@@ -8822,6 +8822,8 @@
   /// If this expression is both in a getter and setter context, the
   /// [AuxiliaryElements] will be set to hold onto the static element from the
   /// getter context.
+  @Deprecated('Use CompoundAssignmentExpression.readElement and/or '
+      'CompoundAssignmentExpression.writeElement')
   @override
   AuxiliaryElements auxiliaryElements;
 
diff --git a/pkg/analyzer/lib/src/dart/ast/utilities.dart b/pkg/analyzer/lib/src/dart/ast/utilities.dart
index 1c7ffd9..4a4bd24 100644
--- a/pkg/analyzer/lib/src/dart/ast/utilities.dart
+++ b/pkg/analyzer/lib/src/dart/ast/utilities.dart
@@ -5137,6 +5137,7 @@
     if (_isEqualTokens(node.token, toNode.token)) {
       toNode.staticElement = node.staticElement;
       toNode.staticType = node.staticType;
+      // ignore: deprecated_member_use_from_same_package
       toNode.auxiliaryElements = node.auxiliaryElements;
       (toNode as SimpleIdentifierImpl).tearOffTypeArgumentTypes =
           node.tearOffTypeArgumentTypes;
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 42e94d4..558ee7d 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -683,6 +683,7 @@
     if (hasRead) {
       var readElement = assignment.readElement;
       if (readElement is PropertyAccessorElement) {
+        // ignore: deprecated_member_use_from_same_package
         leftIdentifier.auxiliaryElements = AuxiliaryElements(readElement);
       }
     }
diff --git a/pkg/analyzer/pubspec.yaml b/pkg/analyzer/pubspec.yaml
index 9bfb00a..9eea80c 100644
--- a/pkg/analyzer/pubspec.yaml
+++ b/pkg/analyzer/pubspec.yaml
@@ -1,5 +1,5 @@
 name: analyzer
-version: 0.40.3
+version: 0.40.4-dev
 description: This package provides a library that performs static analysis of Dart code.
 homepage: https://github.com/dart-lang/sdk/tree/master/pkg/analyzer
 
diff --git a/pkg/analyzer/test/generated/simple_resolver_test.dart b/pkg/analyzer/test/generated/simple_resolver_test.dart
index db7b889..147d0ebd 100644
--- a/pkg/analyzer/test/generated/simple_resolver_test.dart
+++ b/pkg/analyzer/test/generated/simple_resolver_test.dart
@@ -538,37 +538,6 @@
     verifyTestResolved();
   }
 
-  test_getter_and_setter_fromMixins_property_access() async {
-    await assertNoErrorsInCode(r'''
-class B {}
-class M1 {
-  get x => null;
-  set x(value) {}
-}
-class M2 {
-  get x => null;
-  set x(value) {}
-}
-class C extends B with M1, M2 {}
-void main() {
-  new C().x += 1;
-}
-''');
-    verifyTestResolved();
-
-    // Verify that both the getter and setter for "x" in "new C().x" refer to
-    // the accessors defined in M2.
-    var leftHandSide = findNode.simple('x +=');
-    expect(
-      leftHandSide.staticElement,
-      findElement.setter('x', of: 'M2'),
-    );
-    expect(
-      leftHandSide.auxiliaryElements.staticElement,
-      findElement.getter('x', of: 'M2'),
-    );
-  }
-
   test_getter_fromMixins_bare_identifier() async {
     await assertNoErrorsInCode('''
 class B {}
diff --git a/pkg/analyzer/test/src/dart/ast/utilities_test.dart b/pkg/analyzer/test/src/dart/ast/utilities_test.dart
index d3699e0..0e1dca2 100644
--- a/pkg/analyzer/test/src/dart/ast/utilities_test.dart
+++ b/pkg/analyzer/test/src/dart/ast/utilities_test.dart
@@ -852,12 +852,14 @@
     MethodElement staticElement = ElementFactory.methodElement(
         "m", interfaceTypeStar(ElementFactory.classElement2('C')));
     AuxiliaryElements auxiliaryElements = AuxiliaryElements(staticElement);
+    // ignore: deprecated_member_use_from_same_package
     fromNode.auxiliaryElements = auxiliaryElements;
     fromNode.staticElement = staticElement;
     DartType staticType = interfaceTypeStar(ElementFactory.classElement2('C'));
     fromNode.staticType = staticType;
     SimpleIdentifier toNode = AstTestFactory.identifier3("x");
     ResolutionCopier.copyResolutionData(fromNode, toNode);
+    // ignore: deprecated_member_use_from_same_package
     expect(toNode.auxiliaryElements, same(auxiliaryElements));
     expect(toNode.staticElement, same(staticElement));
     expect(toNode.staticType, same(staticType));
diff --git a/pkg/analyzer/test/src/dart/resolution/assignment_test.dart b/pkg/analyzer/test/src/dart/resolution/assignment_test.dart
index 155270f..1af5544 100644
--- a/pkg/analyzer/test/src/dart/resolution/assignment_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/assignment_test.dart
@@ -1094,6 +1094,43 @@
     assertType(assignment.rightHandSide, 'int');
   }
 
+  test_propertyAccess_instance_fromMixins_compound() async {
+    await assertNoErrorsInCode('''
+class M1 {
+  int get x => 0;
+  set x(num _) {}
+}
+
+class M2 {
+  int get x => 0;
+  set x(num _) {}
+}
+
+class C with M1, M2 {
+}
+
+void f(C c) {
+  (c).x += 2;
+}
+''');
+
+    var assignment = findNode.assignment('x += 2');
+    assertAssignment(
+      assignment,
+      readElement: findElement.getter('x', of: 'M2'),
+      readType: 'int',
+      writeElement: findElement.setter('x', of: 'M2'),
+      writeType: 'num',
+      operatorElement: elementMatcher(
+        numElement.getMethod('+'),
+        isLegacy: isNullSafetySdkAndLegacyLibrary,
+      ),
+      type: 'int',
+    );
+
+    assertType(assignment.rightHandSide, 'int');
+  }
+
   test_propertyAccess_instance_simple() async {
     await assertNoErrorsInCode(r'''
 class A {
diff --git a/pkg/analyzer/test/src/dart/resolution/extension_override_test.dart b/pkg/analyzer/test/src/dart/resolution/extension_override_test.dart
index 9bf497b..ddcd447 100644
--- a/pkg/analyzer/test/src/dart/resolution/extension_override_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/extension_override_test.dart
@@ -593,6 +593,7 @@
       if (access.propertyName.inGetterContext()) {
         PropertyAccessorElement expectedGetter = extension.getGetter('s');
         Element actualGetter =
+            // ignore: deprecated_member_use_from_same_package
             access.propertyName.auxiliaryElements.staticElement;
         expect(actualGetter, expectedGetter);
       }
diff --git a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
index a7945a6..af3b5a9 100644
--- a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
+++ b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
@@ -1148,7 +1148,6 @@
     _writeNextCodeLine(node);
     _writeln('SimpleIdentifier');
     _withIndent(() {
-      _writeAuxiliaryElements('auxiliaryElements', node.auxiliaryElements);
       _writeElement('staticElement', node.staticElement);
       _writeType('staticType', node.staticType);
       _writeToken('token', node.token);
@@ -1677,14 +1676,6 @@
     _indent = indent;
   }
 
-  void _writeAuxiliaryElements(String name, AuxiliaryElements elements) {
-    if (elements != null) {
-      _sink.write(_indent);
-      _sink.write('$name: ');
-      _writeElement0(elements.staticElement);
-    }
-  }
-
   void _writeElement(String name, Element element) {
     _sink.write(_indent);
     _sink.write('$name: ');