jbee/purejin

Allow Managed Instances with Type Variables use these in Constructors and Methods

Closed this issue · 1 comments

jbee commented

When a type is constructed that has a type variable, e.g.

class MyGenericType<T> {
  //...
}

the type variable could occur in the parameters of a constructor or method, in which case the type variable should be substituted to the actual type based on what dependency is resolved.

class MyGenericType<T> {
  MyGenericType(T value) {
    //...
  }
}

For example when the above is resolved for MyGenericType<String> the context should attempt to inject String not Object.

jbee commented

For methods a Hint can be added and used to refer the exact target type.

Currently when the owner is not already known from a constant it is resolved by Class type:

owner = context.resolve(producer.target.getDeclaringClass());

This does not allow for any type parameters. Here a Hint could be used instead which has the fully generic Type available to resolve the owner and add the actual type to the replacement map before the call is executed.