fix(di): allow `@Inject(…)` to work in dart2js and dynamic reflection

Note: We can’t write a unit test for this as our unit tests
are running in Dartium, where the error does not occur.
However, we previously had a failure in our e2e tests
in `hello_world/index_dynamic.html`
when removing the TODOs in `application.ts`.

Closes #2185
This commit is contained in:
Tobias Bosch 2015-05-27 10:28:15 -07:00
parent 608017776e
commit 4a3fd5e855
2 changed files with 4 additions and 11 deletions

View File

@ -103,19 +103,12 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
.toFactory((styleUrlResolver, doc) => .toFactory((styleUrlResolver, doc) =>
new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, doc.head), new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, doc.head),
[StyleUrlResolver, DOCUMENT_TOKEN]), [StyleUrlResolver, DOCUMENT_TOKEN]),
// TODO(tbosch): We need an explicit factory here, as DomRenderer,
// we are getting errors in dart2js with mirrors...
bind(DomRenderer)
.toFactory((eventManager, shadowDomStrategy, doc) =>
new DomRenderer(eventManager, shadowDomStrategy, doc),
[EventManager, ShadowDomStrategy, DOCUMENT_TOKEN]),
DefaultDomCompiler, DefaultDomCompiler,
bind(Renderer).toAlias(DomRenderer), bind(Renderer).toAlias(DomRenderer),
bind(RenderCompiler).toAlias(DefaultDomCompiler), bind(RenderCompiler).toAlias(DefaultDomCompiler),
ProtoViewFactory, ProtoViewFactory,
// TODO(tbosch): We need an explicit factory here, as AppViewPool,
// we are getting errors in dart2js with mirrors...
bind(AppViewPool).toFactory((capacity) => new AppViewPool(capacity), [APP_VIEW_POOL_CAPACITY]),
bind(APP_VIEW_POOL_CAPACITY).toValue(10000), bind(APP_VIEW_POOL_CAPACITY).toValue(10000),
AppViewManager, AppViewManager,
AppViewManagerUtils, AppViewManagerUtils,

View File

@ -57,8 +57,8 @@ class ReflectionCapabilities {
} }
List _convertParameter(ParameterMirror p) { List _convertParameter(ParameterMirror p) {
var t = p.type.reflectedType; var t = p.type;
var res = t == dynamic ? [] : [t]; var res = (!t.hasReflectedType || t.reflectedType == dynamic) ? [] : [t.reflectedType];
res.addAll(p.metadata.map((m) => m.reflectee)); res.addAll(p.metadata.map((m) => m.reflectee));
return res; return res;
} }