Skip to content

Commit 4a3fd5e

Browse files
committed
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 angular#2185
1 parent 6080177 commit 4a3fd5e

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

modules/angular2/src/core/application.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,12 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
103103
.toFactory((styleUrlResolver, doc) =>
104104
new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, doc.head),
105105
[StyleUrlResolver, DOCUMENT_TOKEN]),
106-
// TODO(tbosch): We need an explicit factory here, as
107-
// we are getting errors in dart2js with mirrors...
108-
bind(DomRenderer)
109-
.toFactory((eventManager, shadowDomStrategy, doc) =>
110-
new DomRenderer(eventManager, shadowDomStrategy, doc),
111-
[EventManager, ShadowDomStrategy, DOCUMENT_TOKEN]),
106+
DomRenderer,
112107
DefaultDomCompiler,
113108
bind(Renderer).toAlias(DomRenderer),
114109
bind(RenderCompiler).toAlias(DefaultDomCompiler),
115110
ProtoViewFactory,
116-
// TODO(tbosch): We need an explicit factory here, as
117-
// we are getting errors in dart2js with mirrors...
118-
bind(AppViewPool).toFactory((capacity) => new AppViewPool(capacity), [APP_VIEW_POOL_CAPACITY]),
111+
AppViewPool,
119112
bind(APP_VIEW_POOL_CAPACITY).toValue(10000),
120113
AppViewManager,
121114
AppViewManagerUtils,

modules/angular2/src/reflection/reflection_capabilities.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ class ReflectionCapabilities {
5757
}
5858

5959
List _convertParameter(ParameterMirror p) {
60-
var t = p.type.reflectedType;
61-
var res = t == dynamic ? [] : [t];
60+
var t = p.type;
61+
var res = (!t.hasReflectedType || t.reflectedType == dynamic) ? [] : [t.reflectedType];
6262
res.addAll(p.metadata.map((m) => m.reflectee));
6363
return res;
6464
}

0 commit comments

Comments
 (0)