Clear static ElementFactory state at the start of all resolver tests.
This prevents the ElementFactory's ClassElement for `Object` (which it stores statically) from getting accidentally shared between separate unit tests in a single test run, which could cause state to leak between the tests. R=brianwilkerson@google.com Review URL: https://codereview.chromium.org/1752023002 .
This commit is contained in:
@@ -251,6 +251,15 @@ class ElementFactory {
|
||||
Identifier name) =>
|
||||
new FieldFormalParameterElementImpl.forNode(name);
|
||||
|
||||
/**
|
||||
* Destroy any static state retained by [ElementFactory]. This should be
|
||||
* called from the `setUp` method of any tests that use [ElementFactory], in
|
||||
* order to ensure that state is not shared between multiple tests.
|
||||
*/
|
||||
static void flushStaticState() {
|
||||
_objectElement = null;
|
||||
}
|
||||
|
||||
static FunctionElementImpl functionElement(String functionName) =>
|
||||
functionElement4(functionName, null, null, null, null);
|
||||
|
||||
|
||||
@@ -8497,6 +8497,7 @@ class ResolverTestCase extends EngineTestCase {
|
||||
|
||||
@override
|
||||
void setUp() {
|
||||
ElementFactory.flushStaticState();
|
||||
super.setUp();
|
||||
reset();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user