Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
fix(MetadataExtractor): ignore typedefs
Browse files Browse the repository at this point in the history
Fixes #524
  • Loading branch information
pavelgj committed Feb 7, 2014
1 parent 73bf0d3 commit 37f1c32
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/core/registry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ abstract class AnnotationsMap<K> {
@NgInjectableService()
class MetadataExtractor {
Iterable call(Type type) {
if (reflectType(type) is TypedefMirror) return [];
var metadata = reflectClass(type).metadata;
if (metadata == null) return [];
return metadata.map((InstanceMirror im) => im.reflectee);
Expand Down
12 changes: 12 additions & 0 deletions test/core/registry_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,20 @@ main() => describe('RegistryMap', () {
expect(keys).toEqual([new MyAnnotation('A'), new MyAnnotation('B')]);
expect(types).toEqual([A1, A1]);
});

it('should safely ignore typedefs', () {
var module = new Module()
..type(MyMap)
..type(MetadataExtractor)
..value(MyTypedef, (String _) => null);

var injector = new DynamicInjector(modules: [module]);
expect(() => injector.get(MyMap), isNot(throws));
});
});

typedef void MyTypedef(String arg);

class MyMap extends AnnotationMap<MyAnnotation> {
MyMap(Injector injector, MetadataExtractor metadataExtractor)
: super(injector, metadataExtractor);
Expand Down

0 comments on commit 37f1c32

Please sign in to comment.