From 15164a8e6cd3f6c8fda5520a26b9f30795bd8737 Mon Sep 17 00:00:00 2001
From: vsavkin <avix1000@gmail.com>
Date: Fri, 4 Sep 2015 16:36:08 -0700
Subject: [PATCH] fix(reflector): merge prop metadata from getters and setters

Closes #4006
---
 .../src/core/reflection/reflection_capabilities.dart   |  3 ++-
 .../test/core/reflection/reflector_common.dart         |  5 +++++
 .../angular2/test/core/reflection/reflector_common.ts  |  3 +++
 .../angular2/test/core/reflection/reflector_spec.ts    | 10 +++++++++-
 4 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/modules/angular2/src/core/reflection/reflection_capabilities.dart b/modules/angular2/src/core/reflection/reflection_capabilities.dart
index 1138d7eee1..0d77f3fadb 100644
--- a/modules/angular2/src/core/reflection/reflection_capabilities.dart
+++ b/modules/angular2/src/core/reflection/reflection_capabilities.dart
@@ -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;
   }
diff --git a/modules/angular2/test/core/reflection/reflector_common.dart b/modules/angular2/test/core/reflection/reflector_common.dart
index f01598e823..d6ee459713 100644
--- a/modules/angular2/test/core/reflection/reflector_common.dart
+++ b/modules/angular2/test/core/reflection/reflector_common.dart
@@ -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) {}
+}
\ No newline at end of file
diff --git a/modules/angular2/test/core/reflection/reflector_common.ts b/modules/angular2/test/core/reflection/reflector_common.ts
index 84223fda9b..8bcd42f65e 100644
--- a/modules/angular2/test/core/reflection/reflector_common.ts
+++ b/modules/angular2/test/core/reflection/reflector_common.ts
@@ -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 {}
\ No newline at end of file
diff --git a/modules/angular2/test/core/reflection/reflector_spec.ts b/modules/angular2/test/core/reflection/reflector_spec.ts
index f776c301a0..26adf7e325 100644
--- a/modules/angular2/test/core/reflection/reflector_spec.ts
+++ b/modules/angular2/test/core/reflection/reflector_spec.ts
@@ -7,7 +7,8 @@ import {
   PropDecorator,
   classDecorator,
   paramDecorator,
-  propDecorator
+  propDecorator,
+  HasGetterAndSetterDecorators
 } from './reflector_common';
 import {IS_DART} from '../../platform';
 
@@ -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", () => {