Commit be72f333 authored by Ian Hickson's avatar Ian Hickson

Merge pull request #1440 from Hixie/createState

Assert that the widget is the T in State<T>
parents 603e1efb 83416544
......@@ -293,6 +293,10 @@ abstract class State<T extends StatefulComponent> {
/// This is used to verify that State objects move through life in an orderly fashion.
_StateLifecycle _debugLifecycleState = _StateLifecycle.created;
/// Verifies that the State that was created is one that expects to be created
/// for that particular Widget.
bool _debugTypesAreRight(widget) => widget is T;
/// Pointer to the owner Element object
StatefulComponentElement _element;
......@@ -824,6 +828,7 @@ class StatelessComponentElement<T extends StatelessComponent> extends BuildableE
class StatefulComponentElement extends BuildableElement<StatefulComponent> {
StatefulComponentElement(StatefulComponent widget)
: _state = widget.createState(), super(widget) {
assert(_state._debugTypesAreRight(widget));
assert(_state._element == null);
_state._element = this;
assert(_builder == null);
......
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