google / reflectable.dart

Reflectable is a Dart library that allows programmers to eliminate certain usages of dynamic reflection by specialization of reflective code to an equivalent implementation using only static techniques. The use of dynamic reflection is constrained in order to ensure that the specialized code can be generated and will have a reasonable size.

Home Page:https://pub.dev/packages/reflectable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistency with both typeAnnotationQuantifyCapability and superclassQuantifyCapability

Dimibe opened this issue · comments

When using the two capabilities typeAnnotationQuantifyCapability and superclassQuantifyCapability combined, the covered reflectable classes are not as expected.

Type annotations from super classes are reflectable, but super classes of type annotations are not. According to the code documentation, my expectation is, that in both cases all classes must be reflectable.

Consider the following Reflector:

class Reflector extends Reflectable {
  const Reflector()
      : super(instanceInvokeCapability, reflectedTypeCapability,
            typeAnnotationQuantifyCapability, superclassQuantifyCapability);
}
const reflector = Reflector();

In the following case, the annotated class A extends a class B which has a class member of type C. In this case, all classes A, B and C are reflectable, which is what I expect.

@reflector
class A extends B { }

class B {
  C? c;
}

class C {}

The second case is the other way around, the annotated class A has a member of type B which extends class C. In this case, only class A and B are reflectable.

@reflector
class A {
 B? b;
}

class B extends C {}

class C {}

My expectation is that class C must be reflectable as well, since the doc of superclassQuantifyCapability is:

Gives support for reflection on all superclasses of covered classes.