diff --git a/modules/di/src/injector.js b/modules/di/src/injector.js index 09ff218c90..b5bb6cf2c2 100644 --- a/modules/di/src/injector.js +++ b/modules/di/src/injector.js @@ -30,19 +30,11 @@ export class Injector { } get(token) { - return this.getByKey(Key.get(token)); + return this._getByKey(Key.get(token), false, false); } asyncGet(token) { - return this.asyncGetByKey(Key.get(token)); - } - - getByKey(key:Key) { - return this._getByKey(key, false, false); - } - - asyncGetByKey(key:Key) { - return this._getByKey(key, true, false); + return this._getByKey(Key.get(token), true, false); } createChild(bindings:List):Injector { diff --git a/modules/di/src/key.js b/modules/di/src/key.js index df85508844..86beb59c6f 100644 --- a/modules/di/src/key.js +++ b/modules/di/src/key.js @@ -13,6 +13,8 @@ export class Key { } static get(token) { + if (token instanceof Key) return token; + if (MapWrapper.contains(_allKeys, token)) { return MapWrapper.get(_allKeys, token) } diff --git a/modules/di/test/di/key_spec.js b/modules/di/test/di/key_spec.js index 8bde3c51f3..cebf492131 100644 --- a/modules/di/test/di/key_spec.js +++ b/modules/di/test/di/key_spec.js @@ -10,5 +10,9 @@ export function main() { it('should not be equal to another key if types are different', function () { expect(Key.get('car')).not.toBe(Key.get('porsche')); }); + + it('should return the passed in key', function () { + expect(Key.get(Key.get('car'))).toBe(Key.get('car')); + }); }); } \ No newline at end of file