Introduce TypeConstructorSubstitution.create

After latest changes type constructors of inner classes contains
additional type parameters that are copies of ones from outer class.

Their indices are correct, but they used only for subtyping check,
all entries within inner classes are still refers to original
descriptors having different indices.

Example:
class Outer<E> {
   inner class Inner<F> { // Inner's type constructor looks like Inner<F, E>
      fun foo(): E // refers to E in outer having index 0
   }
}

Indexed substitution does not work here because of intersecting indices,
so we replace it with common map substituion in such cases.
This commit is contained in:
Denis Zharkov
2015-11-05 20:43:18 +03:00
parent c57dbcc602
commit 188bcf0a03
10 changed files with 29 additions and 24 deletions
@@ -456,7 +456,7 @@ private object ConstantStarSubstitution : TypeSubstitution() {
val newProjections = key.constructor.parameters.map(::StarProjectionImpl)
val substitution = IndexedParametersSubstitution(key.constructor, newProjections)
val substitution = TypeConstructorSubstitution.create(key.constructor, newProjections)
return TypeProjectionImpl(
TypeSubstitutor.create(substitution).substitute(key.constructor.declarationDescriptor!!.defaultType, Variance.INVARIANT)!!
@@ -101,7 +101,7 @@ private fun KotlinType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers
).filterNotNull().compositeAnnotationsOrSingle()
val newSubstitution = computeNewSubstitution(
typeConstructor.parameters, enhancedArguments
typeConstructor, enhancedArguments
)
val enhancedType = KotlinTypeImpl.create(