X Tutup
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ class ReflectionCapabilities implements PlatformReflectionCapabilities {
final res = {};
reflectClass(typeOrFunc).declarations.forEach((k,v) {
var name = _normalizeName(MirrorSystem.getName(k));
res[name] = v.metadata.map((fm) => fm.reflectee).toList();
if (res[name] == null) res[name] = [];
res[name].addAll(v.metadata.map((fm) => fm.reflectee));
});
return res;
}
Expand Down
5 changes: 5 additions & 0 deletions modules/angular2/test/core/reflection/reflector_common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ ParamDecorator paramDecorator(value) {
PropDecorator propDecorator(value) {
return new PropDecorator(value);
}

class HasGetterAndSetterDecorators {
@PropDecorator("get") get a {}
@PropDecorator("set") set a(v) {}
}
3 changes: 3 additions & 0 deletions modules/angular2/test/core/reflection/reflector_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ export function propDecorator(value) {
export var ClassDecorator = makeDecorator(ClassDecoratorMeta);
export var ParamDecorator = makeParamDecorator(ParamDecoratorMeta);
export var PropDecorator = makePropDecorator(PropDecoratorMeta);

// used only in Dart
export class HasGetterAndSetterDecorators {}
10 changes: 9 additions & 1 deletion modules/angular2/test/core/reflection/reflector_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
PropDecorator,
classDecorator,
paramDecorator,
propDecorator
propDecorator,
HasGetterAndSetterDecorators
} from './reflector_common';
import {IS_DART} from '../../platform';

Expand Down Expand Up @@ -160,6 +161,13 @@ export function main() {
reflector.registerType(TestObj, new ReflectionInfo(null, null, null, null, {"a": [1, 2]}));
expect(reflector.propMetadata(TestObj)).toEqual({"a": [1, 2]});
});

if (IS_DART) {
it("should merge metadata from getters and setters", () => {
var p = reflector.propMetadata(HasGetterAndSetterDecorators);
expect(p["a"]).toEqual([propDecorator("get"), propDecorator("set")]);
});
}
});

describe("annotations", () => {
Expand Down
X Tutup