fix(di): throw if a token uses more than 20 dependencies.

Fixes #6690
Closes #6869
This commit is contained in:
Tobias Bosch
2016-02-03 09:51:24 -08:00
committed by Igor Minar
parent e73fee7156
commit de77700da0
2 changed files with 47 additions and 0 deletions

View File

@ -17,6 +17,7 @@ import {
OutOfBoundsError
} from './exceptions';
import {FunctionWrapper, Type, isPresent, isBlank, CONST_EXPR} from 'angular2/src/facade/lang';
import {BaseException} from 'angular2/src/facade/exceptions';
import {Key} from './key';
import {SelfMetadata, HostMetadata, SkipSelfMetadata} from './metadata';
@ -874,6 +875,9 @@ export class Injector {
obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16,
d17, d18, d19);
break;
default:
throw new BaseException(
`Cannot instantiate '${provider.key.displayName}' because it has more than 20 dependencies`);
}
} catch (e) {
throw new InstantiationError(this, e, e.stack, provider.key);