Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: pkg/analyzer/test/src/task/incremental_element_builder_test.dart

Issue 2156873002: Invalidate resolution if a unit instantiate a class with the unnamed constructor change. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/test/src/context/context_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/task/incremental_element_builder_test.dart
diff --git a/pkg/analyzer/test/src/task/incremental_element_builder_test.dart b/pkg/analyzer/test/src/task/incremental_element_builder_test.dart
index a605a69cd4f6ce4acebb0d172170c66fb583b2e4..3761bb6e431c85d67d017a0a4587f53efb03943c 100644
--- a/pkg/analyzer/test/src/task/incremental_element_builder_test.dart
+++ b/pkg/analyzer/test/src/task/incremental_element_builder_test.dart
@@ -66,6 +66,7 @@ class A {
ClassElement classElement = helper.element;
expect(classElement.constructors, unorderedEquals([newConstructorElement]));
// verify delta
+ expect(helper.delta.hasUnnamedConstructorChange, isTrue);
expect(helper.delta.addedConstructors,
unorderedEquals([newConstructorElement]));
expect(helper.delta.removedConstructors,
@@ -99,7 +100,9 @@ class A {
expect(constructors[0].isSynthetic, isTrue);
}
// verify delta
- expect(helper.delta.addedConstructors, unorderedEquals([]));
+ expect(helper.delta.hasUnnamedConstructorChange, isTrue);
+ expect(helper.delta.addedConstructors,
+ unorderedEquals([classElement.unnamedConstructor]));
expect(helper.delta.removedConstructors, unorderedEquals([oldElementA]));
expect(helper.delta.addedAccessors, isEmpty);
expect(helper.delta.removedAccessors, isEmpty);
@@ -107,6 +110,66 @@ class A {
expect(helper.delta.removedMethods, isEmpty);
}
+ test_classDelta_constructor_1to1_unnamed_addParameter() {
+ var helper = new _ClassDeltaHelper('A');
+ _buildOldUnit(r'''
+class A {
+ A();
+}
+''');
+ helper.initOld(oldUnit);
+ ConstructorElement oldConstructor = helper.element.unnamedConstructor;
+ _buildNewUnit(r'''
+class A {
+ A(int p);
+}
+''');
+ helper.initNew(newUnit, unitDelta);
+ ClassElement classElement = helper.element;
+ ConstructorElement newConstructor = classElement.unnamedConstructor;
+ expect(classElement.constructors, [newConstructor]);
+ // verify delta
+ expect(helper.delta.hasUnnamedConstructorChange, isTrue);
+ expect(helper.delta.addedConstructors, unorderedEquals([newConstructor]));
+ expect(helper.delta.removedConstructors, unorderedEquals([oldConstructor]));
+ expect(helper.delta.addedAccessors, isEmpty);
+ expect(helper.delta.removedAccessors, isEmpty);
+ expect(helper.delta.addedMethods, isEmpty);
+ expect(helper.delta.removedMethods, isEmpty);
+ }
+
+ test_classDelta_constructor_1to1_unnamed_removeParameter() {
+ var helper = new _ClassDeltaHelper('A');
+ _buildOldUnit(r'''
+class A {
+ final int a;
+ final int b;
+ A(this.a, this.b);
+}
+''');
+ helper.initOld(oldUnit);
+ ConstructorElement oldConstructor = helper.element.unnamedConstructor;
+ _buildNewUnit(r'''
+class A {
+ final int a;
+ final int b;
+ A(this.a);
+}
+''');
+ helper.initNew(newUnit, unitDelta);
+ ClassElement classElement = helper.element;
+ ConstructorElement newConstructor = classElement.unnamedConstructor;
+ expect(classElement.constructors, [newConstructor]);
+ // verify delta
+ expect(helper.delta.hasUnnamedConstructorChange, isTrue);
+ expect(helper.delta.addedConstructors, unorderedEquals([newConstructor]));
+ expect(helper.delta.removedConstructors, unorderedEquals([oldConstructor]));
+ expect(helper.delta.addedAccessors, isEmpty);
+ expect(helper.delta.removedAccessors, isEmpty);
+ expect(helper.delta.addedMethods, isEmpty);
+ expect(helper.delta.removedMethods, isEmpty);
+ }
+
test_classDelta_constructor_1to2() {
var helper = new _ClassDeltaHelper('A');
_buildOldUnit(r'''
@@ -161,6 +224,7 @@ class A {
}
''');
helper.initNew(newUnit, unitDelta);
+ expect(helper.delta.hasUnnamedConstructorChange, isFalse);
// nodes
ClassMember nodeB = helper.newMembers[0];
expect(nodeB, same(helper.oldMembers[1]));
« no previous file with comments | « pkg/analyzer/test/src/context/context_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698