fix(bug): reflect Dart interfaces from superclass as well

fixes #4221

Closes #4222
This commit is contained in:
Alex Eagle 2015-09-16 16:16:03 -07:00 committed by Alex Eagle
parent 9dd32d658e
commit 577ee3744a
2 changed files with 13 additions and 4 deletions

View File

@ -272,8 +272,13 @@ class ReflectionCapabilities implements PlatformReflectionCapabilities {
} }
List interfaces(type) { List interfaces(type) {
ClassMirror classMirror = reflectType(type); return _interfacesFromMirror(reflectType(type));
return classMirror.superinterfaces.map((si) => si.reflectedType).toList(); }
List _interfacesFromMirror(classMirror) {
return classMirror.superinterfaces.map((si) => si.reflectedType).toList()
..addAll(classMirror.superclass == null ? []
: _interfacesFromMirror(classMirror.superclass));
} }
GetterFn getter(String name) { GetterFn getter(String name) {

View File

@ -51,7 +51,11 @@ class TestObj {
class Interface {} class Interface {}
class ClassImplementingInterface implements Interface {} class Interface2 {}
class SuperClassImplementingInterface implements Interface2 {}
class ClassImplementingInterface extends SuperClassImplementingInterface implements Interface {}
export function main() { export function main() {
describe('Reflector', () => { describe('Reflector', () => {
@ -191,7 +195,7 @@ export function main() {
describe("interfaces", () => { describe("interfaces", () => {
it("should return an array of interfaces for a type", () => { it("should return an array of interfaces for a type", () => {
var p = reflector.interfaces(ClassImplementingInterface); var p = reflector.interfaces(ClassImplementingInterface);
expect(p).toEqual([Interface]); expect(p).toEqual([Interface, Interface2]);
}); });
it("should return an empty array otherwise", () => { it("should return an empty array otherwise", () => {