Unverified Commit 2dc71a34 authored by chunhtai's avatar chunhtai Committed by GitHub

reland Refactors global key duplication detection (#49896)

* reland "Refactors global key duplication detection (#46183)"

This reverts commit d2b66dbf.

* fix test
parent 2c51efef
...@@ -469,6 +469,7 @@ class _CupertinoAlertRenderElement extends RenderObjectElement { ...@@ -469,6 +469,7 @@ class _CupertinoAlertRenderElement extends RenderObjectElement {
} else if (_actionsElement == child) { } else if (_actionsElement == child) {
_actionsElement = null; _actionsElement = null;
} }
super.forgetChild(child);
} }
@override @override
......
...@@ -464,6 +464,7 @@ class _CupertinoDialogRenderElement extends RenderObjectElement { ...@@ -464,6 +464,7 @@ class _CupertinoDialogRenderElement extends RenderObjectElement {
assert(_actionsElement == child); assert(_actionsElement == child);
_actionsElement = null; _actionsElement = null;
} }
super.forgetChild(child);
} }
@override @override
......
...@@ -2072,6 +2072,7 @@ class _RenderChipElement extends RenderObjectElement { ...@@ -2072,6 +2072,7 @@ class _RenderChipElement extends RenderObjectElement {
final _ChipSlot slot = childToSlot[child]; final _ChipSlot slot = childToSlot[child];
childToSlot.remove(child); childToSlot.remove(child);
slotToChild.remove(slot); slotToChild.remove(slot);
super.forgetChild(child);
} }
void _mountChild(Widget widget, _ChipSlot slot) { void _mountChild(Widget widget, _ChipSlot slot) {
......
...@@ -1511,6 +1511,7 @@ class _RenderDecorationElement extends RenderObjectElement { ...@@ -1511,6 +1511,7 @@ class _RenderDecorationElement extends RenderObjectElement {
final _DecorationSlot slot = childToSlot[child]; final _DecorationSlot slot = childToSlot[child];
childToSlot.remove(child); childToSlot.remove(child);
slotToChild.remove(slot); slotToChild.remove(slot);
super.forgetChild(child);
} }
void _mountChild(Widget widget, _DecorationSlot slot) { void _mountChild(Widget widget, _DecorationSlot slot) {
......
...@@ -992,6 +992,7 @@ class _ListTileElement extends RenderObjectElement { ...@@ -992,6 +992,7 @@ class _ListTileElement extends RenderObjectElement {
final _ListTileSlot slot = childToSlot[child]; final _ListTileSlot slot = childToSlot[child];
childToSlot.remove(child); childToSlot.remove(child);
slotToChild.remove(slot); slotToChild.remove(slot);
super.forgetChild(child);
} }
void _mountChild(Widget widget, _ListTileSlot slot) { void _mountChild(Widget widget, _ListTileSlot slot) {
......
...@@ -1016,6 +1016,7 @@ class RenderObjectToWidgetElement<T extends RenderObject> extends RootRenderObje ...@@ -1016,6 +1016,7 @@ class RenderObjectToWidgetElement<T extends RenderObject> extends RootRenderObje
void forgetChild(Element child) { void forgetChild(Element child) {
assert(child == _child); assert(child == _child);
_child = null; _child = null;
super.forgetChild(child);
} }
@override @override
......
...@@ -60,6 +60,7 @@ class _LayoutBuilderElement<ConstraintType extends Constraints> extends RenderOb ...@@ -60,6 +60,7 @@ class _LayoutBuilderElement<ConstraintType extends Constraints> extends RenderOb
void forgetChild(Element child) { void forgetChild(Element child) {
assert(child == _child); assert(child == _child);
_child = null; _child = null;
super.forgetChild(child);
} }
@override @override
......
...@@ -924,6 +924,7 @@ class ListWheelElement extends RenderObjectElement implements ListWheelChildMana ...@@ -924,6 +924,7 @@ class ListWheelElement extends RenderObjectElement implements ListWheelChildMana
@override @override
void forgetChild(Element child) { void forgetChild(Element child) {
_childElements.remove(child.slot); _childElements.remove(child.slot);
super.forgetChild(child);
} }
} }
......
...@@ -1160,6 +1160,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render ...@@ -1160,6 +1160,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
assert(child.slot != null); assert(child.slot != null);
assert(_childElements.containsKey(child.slot)); assert(_childElements.containsKey(child.slot));
_childElements.remove(child.slot); _childElements.remove(child.slot);
super.forgetChild(child);
} }
@override @override
......
...@@ -230,6 +230,7 @@ class _SliverPersistentHeaderElement extends RenderObjectElement { ...@@ -230,6 +230,7 @@ class _SliverPersistentHeaderElement extends RenderObjectElement {
void forgetChild(Element child) { void forgetChild(Element child) {
assert(child == this.child); assert(child == this.child);
this.child = null; this.child = null;
super.forgetChild(child);
} }
@override @override
......
...@@ -344,6 +344,7 @@ class _TableElement extends RenderObjectElement { ...@@ -344,6 +344,7 @@ class _TableElement extends RenderObjectElement {
@override @override
bool forgetChild(Element child) { bool forgetChild(Element child) {
_forgottenChildren.add(child); _forgottenChildren.add(child);
super.forgetChild(child);
return true; return true;
} }
} }
......
...@@ -221,11 +221,6 @@ void main() { ...@@ -221,11 +221,6 @@ void main() {
class _TestElement extends Element { class _TestElement extends Element {
_TestElement() : super(const Placeholder()); _TestElement() : super(const Placeholder());
@override
void forgetChild(Element child) {
// Intentionally left empty.
}
@override @override
void performRebuild() { void performRebuild() {
// Intentionally left empty. // Intentionally left empty.
......
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