From 577ee3744acf704b5b5fa9785a1f3bd8d644e66e Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Wed, 16 Sep 2015 16:16:03 -0700 Subject: [PATCH] fix(bug): reflect Dart interfaces from superclass as well fixes #4221 Closes #4222 --- .../src/core/reflection/reflection_capabilities.dart | 9 +++++++-- modules/angular2/test/core/reflection/reflector_spec.ts | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/angular2/src/core/reflection/reflection_capabilities.dart b/modules/angular2/src/core/reflection/reflection_capabilities.dart index fe9211466d..9fff8f5de7 100644 --- a/modules/angular2/src/core/reflection/reflection_capabilities.dart +++ b/modules/angular2/src/core/reflection/reflection_capabilities.dart @@ -272,8 +272,13 @@ class ReflectionCapabilities implements PlatformReflectionCapabilities { } List interfaces(type) { - ClassMirror classMirror = reflectType(type); - return classMirror.superinterfaces.map((si) => si.reflectedType).toList(); + return _interfacesFromMirror(reflectType(type)); + } + + List _interfacesFromMirror(classMirror) { + return classMirror.superinterfaces.map((si) => si.reflectedType).toList() + ..addAll(classMirror.superclass == null ? [] + : _interfacesFromMirror(classMirror.superclass)); } GetterFn getter(String name) { diff --git a/modules/angular2/test/core/reflection/reflector_spec.ts b/modules/angular2/test/core/reflection/reflector_spec.ts index 273b9e77cd..28753a7bf0 100644 --- a/modules/angular2/test/core/reflection/reflector_spec.ts +++ b/modules/angular2/test/core/reflection/reflector_spec.ts @@ -51,7 +51,11 @@ class TestObj { class Interface {} -class ClassImplementingInterface implements Interface {} +class Interface2 {} + +class SuperClassImplementingInterface implements Interface2 {} + +class ClassImplementingInterface extends SuperClassImplementingInterface implements Interface {} export function main() { describe('Reflector', () => { @@ -191,7 +195,7 @@ export function main() { describe("interfaces", () => { it("should return an array of interfaces for a type", () => { var p = reflector.interfaces(ClassImplementingInterface); - expect(p).toEqual([Interface]); + expect(p).toEqual([Interface, Interface2]); }); it("should return an empty array otherwise", () => {