Before this change generic signature wasn't written because of wrong
assumption about it absence in all cases where we replace generic parameter
with Object
By default we would render 'MutableCollection<String>.addAll(Collection<String>)' as
'(LCollection<String>;)' (without wildcard) because String is final and
effectively it's the same as '(LCollection<? extends String>;)'.
But that's wrong signature in a sense that java.util.Collection has different
signature: '(LCollection<? extends E>)'.
Actually the problem is much wider than collections,
it concerns any Java code that uses Kotlin classes with covariant
parameters without '? extends E' wildcards.
Temporary solution is just to hardcode/enumerate builtin methods
with special signature.
Generate special bridge even in case current class has Kotlin superclass implementing
this builtin method, but that super class was generated without special bridge
(e.g. because it would have the same signature)
#KT-9901 Fixed
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.
Mostly it's needed for backend to extract descriptor with initial signature
For example:
class A implements CharSequence {
char charAt(int index) {}
}
We see `charAt` this method as `fun get(index: Int): Char`, but in backend it
matters what signature had this descriptor before.
Create all of them --- both renamed and with de-erased signature ---
within 'computeNonDeclaredFunctions'.
This helps to get rid of open 'resolveMethodToFunctionDescriptor'
and guarantees that method inside 'isVisibleAsFunction'
is always without any magic.