Inject tag is processed before Dispatcher tag, then null pointer exception happens.

Description

Having something like:

ClassA implements IEventDispatcher{

[Dispatcher]
public var eventBus:IEventDispatcher;
....

}

ClassB extends ClassA{

[Inject("appModel")]
[Bindable]
public var model:MainAppModel;
...
}

Since swiz process inject tags before dispatcher tags when model is injected since flex sdk has added logic to dispatch this the change event and dispatcher is null because the dispatcher tag hasn't been processed then a null pointer exception ocurrs.
This seems to me as a compatibility issue between Flex and Swiz.
(in the attached project I'm using a modified version of the swiz framework)

Phases:
0 - Flex sdk compiles the code and add to the bindable property "model" of ClassB the logic necesary to dispatch the event when it changes. Since ClassB extends ClassA and ClassA implements IEventDispatcher flex sdk does not add an EventDispatcher instance to it.
1 - Swiz creates a ClassB instance
2 - Swiz injects the model.
3 - Flex automatically created code invokes the ClassB instance dispatch method to broadcast the propertyChange event
4 - Since Swiz hasn't injected the eventdispatcher instance on the "eventBus" property this fails.
5 - Null pointer exception error arises.

Fix:
In the class ProcessorPriority class
changing this
public static const DISPATCHER :int = 700;
to:
public static const DISPATCHER :int = 750;

to make DISPATCHER to be processed just before INJECT.

Environment

Flex 4 web app.

Status

Assignee

ChrisC

Reporter

FedericoJ

Labels

None

Affects versions

Priority

Major
Configure