Unverified Commit 4cf1a350 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Remove bogus code in ContainerParentDataMixin.detach (#37479)

parent 39a04dcd
...@@ -2834,21 +2834,9 @@ mixin ContainerParentDataMixin<ChildType extends RenderObject> on ParentData { ...@@ -2834,21 +2834,9 @@ mixin ContainerParentDataMixin<ChildType extends RenderObject> on ParentData {
/// Clear the sibling pointers. /// Clear the sibling pointers.
@override @override
void detach() { void detach() {
assert(previousSibling == null, 'Pointers to siblings must be nulled before detaching ParentData.');
assert(nextSibling == null, 'Pointers to siblings must be nulled before detaching ParentData.');
super.detach(); super.detach();
if (previousSibling != null) {
final ContainerParentDataMixin<ChildType> previousSiblingParentData = previousSibling.parentData;
assert(previousSibling != this);
assert(previousSiblingParentData.nextSibling == this);
previousSiblingParentData.nextSibling = nextSibling;
}
if (nextSibling != null) {
final ContainerParentDataMixin<ChildType> nextSiblingParentData = nextSibling.parentData;
assert(nextSibling != this);
assert(nextSiblingParentData.previousSibling == this);
nextSiblingParentData.previousSibling = previousSibling;
}
previousSibling = null;
nextSibling = null;
} }
} }
......
...@@ -81,8 +81,27 @@ void main() { ...@@ -81,8 +81,27 @@ void main() {
), ),
); );
}); });
test('ContainerParentDataMixin requires nulled out pointers to siblings before detach', () {
expect(() => TestParentData().detach(), isNot(throwsAssertionError));
final TestParentData data1 = TestParentData()
..nextSibling = RenderOpacity()
..previousSibling = RenderOpacity();
expect(() => data1.detach(), throwsAssertionError);
final TestParentData data2 = TestParentData()
..previousSibling = RenderOpacity();
expect(() => data2.detach(), throwsAssertionError);
final TestParentData data3 = TestParentData()
..nextSibling = RenderOpacity();
expect(() => data3.detach(), throwsAssertionError);
});
} }
class TestParentData extends ParentData with ContainerParentDataMixin<RenderBox> { }
class TestRenderObject extends RenderObject { class TestRenderObject extends RenderObject {
@override @override
void debugAssertDoesMeetConstraints() { } void debugAssertDoesMeetConstraints() { }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment