Is there a reason why exact matching is used when comparing generic types? Why not stick to isAssignable?
https://github.com/spring-projects/spring-framework/blob/dcc342ccc5cd8cc048c761035ee8cc60a3675c30/spring-core/src/main/java/org/springframework/core/ResolvableType.java#L346-L350
My use case: I am using a generic base event class, such as BaseEvent<T> extends PayloadApplicationEvent<T>, and I am expecting BaseEvent<Y> to fall into a listener expecting BaseEvent<X>, where Y extends X, but that's not happening as the types of X and Y are not equal, but X is assignable from Y.
I would like to precise that I extend PayloadApplicationEvent here but extending ApplicationEvent and implementing ResolvableTypeProvider leads to the same issue.
Is there a way for this to work while using @EventListener? I know that it can be done with the listener implementing GenericApplicationListener but that will lead to messy code.
Any clues? Thanks.
Comment From: rstoyanchev
The change seems to originate with #15844.
Comment From: torshid
Okay so when the listener expects BaseEvent<? extends X> everything works as expected. Seems that this is the expected behavior.