google / google/reflectable.dart

Inconsistency with both typeAnnotationQuantifyCapability and superclassQuantifyCapability

Open
#275 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Dart
Stars
386
Forks
67
PR merge metrics
No merged PRs in 30d

Description

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:

```dart
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.

```dart
@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.

```dart
@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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.