You know what is ``JetType``. ``TypeConstructor`` is a function (mapping) from type parameters to type. When you provide type arguments for ``TypeConstructor``, you get ``JetType``. Each ``TypeConstructor`` is associated with classifier: either class or type parameter descriptor.

Please replace all your type substituting logic with reusing ``TypeSubstitor``. It will simplify everything a lot.