getBeanForSource creates an instance of every Prototype that is a singleton in beans Array who's index is before the actual Prototype that needs to be created

Description

In BeanFactory at line 183 :
for each( var bean:Bean in beans )
{
if( bean is Prototype && ( bean as Prototype ).singleton == false )
continue;
else if(bean.source === source)
return bean;
}

But in Prototype,line 39 :

override public function get source():*
{
return getObject();
}

Line 51:
protected function getObject():*
{
var instance:* = _source;
if( instance == null )
{
// if source is null, create and initialize it (runs all processors)
_source = instance = createInstance();
beanFactory.setUpBean( new Bean( _source, name, typeDescriptor ));

........

As a result all Prototypes that have singleton=true will be instantiated along the way.
Suggested fix:

else if((Class(getDefinitionByName(getQualifiedClassName(source)))==bean.type)&&(bean.source === source))

Environment

None

Status

Assignee

ChrisC

Reporter

Jordan Aanei

Labels

None

Fix versions

Affects versions

Priority

Major
Configure