injectable
injectable copied to clipboard
fix: using interface name for type arguments
this pull request fixes this issue and resolves type arguments using their interface name and import
Consider the following classes:
abstract class InterfaceA<T extends InterfaceAGeneric> {}
@Singleton(as: InterfaceA)
class InterfaceAImpl implements InterfaceA<InterfaceAGenericImpl> {}
abstract class InterfaceB {}
@singleton
class InterfaceBImpl implements InterfaceB {
final InterfaceA _interfaceAInstance;
InterfaceBImpl(this._interfaceAInstance)
}
the generated code would be (fixed):
gh.singleton<_i15.InterfaceA<_i16.InterfaceAGeneric>>(
_i17.InterfaceAImpl(),
);
gh.singleton<_i4.InterfaceB>(
_i4.InterfaceBImpl(
get<_i15.InterfaceA<_i16.InterfaceAGeneric>>(),
),
);
instead of:
gh.singleton<_i15.InterfaceA<_i16.InterfaceAGenericImpl>>(
_i17.InterfaceAImpl(),
);
gh.singleton<_i4.InterfaceB>(
_i4.InterfaceBImpl(
get<_i15.InterfaceA<_i16.InterfaceAGeneric>>(),
),
);
Notice that the registered InterfaceA
is based on InterfaceAGenericImpl
generic, causing an InterfaceBImpl
creation exception due _i15.InterfaceA<_i16.InterfaceAGeneric>
is not retistered.