fix(di): do not use exceptions to detect if reflection is enabled

This commit is contained in:
vsavkin
2015-07-10 08:54:53 -07:00
parent 71c65b47f9
commit a6210466c7
7 changed files with 23 additions and 9 deletions

View File

@ -450,16 +450,15 @@ function _extractToken(typeOrFunc, annotations /*List<any> | any*/,
throw new NoAnnotationError(typeOrFunc, params);
}
}
function _defaulVisiblity(typeOrFunc) {
try {
if (!(typeOrFunc instanceof Type)) return unbounded;
var f =
ListWrapper.filter(reflector.annotations(typeOrFunc), s => s instanceof InjectableMetadata);
return f.length === 0 ? unbounded : f[0].visibility;
} catch (e) {
return unbounded;
}
if (!(typeOrFunc instanceof Type)) return unbounded;
// TODO: vsavkin revisit this after clarifying lookup rules
if (!reflector.isReflectionEnabled()) return unbounded;
var f =
ListWrapper.filter(reflector.annotations(typeOrFunc), s => s instanceof InjectableMetadata);
return f.length === 0 ? unbounded : f[0].visibility;
}
function _createDependency(token, optional, visibility, depProps): Dependency {