@@ -7,6 +7,7 @@ import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
77import { Key } from './key' ;
88
99var _constructing = new Object ( ) ;
10+ var _notFound = new Object ( ) ;
1011
1112class _Waiting {
1213 promise :Promise ;
@@ -72,10 +73,10 @@ export class Injector {
7273 var strategy = returnPromise ? this . _asyncStrategy : this . _syncStrategy ;
7374
7475 var instance = strategy . readFromCache ( key ) ;
75- if ( isPresent ( instance ) ) return instance ;
76+ if ( instance !== _notFound ) return instance ;
7677
7778 instance = strategy . instantiate ( key ) ;
78- if ( isPresent ( instance ) ) return instance ;
79+ if ( instance !== _notFound ) return instance ;
7980
8081 if ( isPresent ( this . _parent ) ) {
8182 return this . _parent . _getByKey ( key , returnPromise , returnLazy , optional ) ;
@@ -148,13 +149,13 @@ class _SyncInjectorStrategy {
148149 } else if ( isPresent ( instance ) && ! _isWaiting ( instance ) ) {
149150 return instance ;
150151 } else {
151- return null ;
152+ return _notFound ;
152153 }
153154 }
154155
155156 instantiate ( key :Key ) {
156157 var binding = this . injector . _getBinding ( key ) ;
157- if ( isBlank ( binding ) ) return null ;
158+ if ( isBlank ( binding ) ) return _notFound ;
158159
159160 if ( binding . providedAsPromise ) throw new AsyncBindingError ( key ) ;
160161
@@ -198,13 +199,13 @@ class _AsyncInjectorStrategy {
198199 } else if ( isPresent ( instance ) ) {
199200 return PromiseWrapper . resolve ( instance ) ;
200201 } else {
201- return null ;
202+ return _notFound ;
202203 }
203204 }
204205
205206 instantiate ( key :Key ) {
206207 var binding = this . injector . _getBinding ( key ) ;
207- if ( isBlank ( binding ) ) return null ;
208+ if ( isBlank ( binding ) ) return _notFound ;
208209
209210 //add a marker so we can detect cyclic dependencies
210211 this . injector . _markAsConstructing ( key ) ;
@@ -243,7 +244,6 @@ class _AsyncInjectorStrategy {
243244 }
244245}
245246
246-
247247function _flattenBindings ( bindings :List , res :Map ) {
248248 ListWrapper . forEach ( bindings , function ( b ) {
249249 if ( b instanceof Binding ) {
0 commit comments