Index: pkg/analyzer/test/src/context/context_test.dart |
diff --git a/pkg/analyzer/test/src/context/context_test.dart b/pkg/analyzer/test/src/context/context_test.dart |
index 54f5619874e1328cac1eebb63ad5b619f892368e..13a5526e6f35aa564a4773087e0e15a4301b28ac 100644 |
--- a/pkg/analyzer/test/src/context/context_test.dart |
+++ b/pkg/analyzer/test/src/context/context_test.dart |
@@ -5395,8 +5395,7 @@ class _ElementComparer extends GeneralizingElementVisitor { |
@override |
void visitElement(Element element) { |
Element previousElement = previousElements[element]; |
- bool expectIdentical = element is! LocalVariableElement; |
- bool ok = expectIdentical |
+ bool ok = _expectedIdentical(element) |
? identical(previousElement, element) |
: previousElement == element; |
if (!ok) { |
@@ -5414,6 +5413,23 @@ class _ElementComparer extends GeneralizingElementVisitor { |
} |
super.visitElement(element); |
} |
+ |
+ /** |
+ * Return `true` if the given [element] should be the same as the previous |
+ * element at the same position in the element model. |
+ */ |
+ static bool _expectedIdentical(Element element) { |
+ while (element != null) { |
+ if (element is ConstructorElement || |
+ element is MethodElement || |
+ element is FunctionElement && |
+ element.enclosingElement is CompilationUnitElement) { |
+ return false; |
+ } |
+ element = element.enclosingElement; |
+ } |
+ return true; |
+ } |
} |
/** |