Proper matching of raw generic types and generically typed factory methods

Also optimized getTypeForFactoryMethod's implementation for non-generic factory methods, and reduced calls to getResolvedFactoryMethod in order to avoid repeated synchronization.

Issue: SPR-11034
Polishing
Added further tests for raw matching of generic types

Issue: SPR-11034
Issue: SPR-11004