Work around type check issues with MODEL_FACTORY_INJECTIONS.

The container subclasses types retrieved via `modelFor`, so that if A is a
subtype of B, modelFor('model:A') will not be a subtype of modelFor('model:B').
This breaks the type check for polymorphic associations.

This commit works around this issue by checking the superclass when doing its
type checks, if MODEL_FACTORY_INJECTIONS is enabled.
Merge pull request #2586 from hjdivad/fix-polymorphic-associations-with-model-factory-injections

Work around type check issues with MODEL_FACTORY_INJECTIONS.