Kotlin: Extract fake overrides for now

When we have Kotlin:

class A {
    fun foo(z: OB<G1, G2>.B<E1, E2>) {
        val foo = z.someFun()
    }
}

and Java:

public class OB<S1, S2> extends OC<F1, F2> {
        public class B<T1, T2> extends OC<F1, F2>.C<D1, D2, T1, T2> {
        }
}

class OC<U1, U2> {
        public class C<X1, X2, Y1, Y2> {
            int someFun() {
                return 5;
            }
        }
}

the `someFun` call is to a fake override, and has 4 type arguments.
If we treat it as calling the real function, then 6 type are expected,
and we get IndexOutOfBoundsException when we try to reorder the
type parameters in orderTypeArgsLeftToRight.

So for now, we just extract the fake overrides, so that we at least
don't crash.
This commit is contained in:
Ian Lynagh
2022-01-24 17:57:39 +00:00
parent 46ccd45833
commit 8d15d0acfb

View File

@@ -511,8 +511,11 @@ open class KotlinFileExtractor(
fun extractFunctionIfReal(f: IrFunction, parentId: Label<out DbReftype>, extractBody: Boolean, typeSubstitution: TypeSubstitution?, classTypeArgsIncludingOuterClasses: List<IrTypeArgument>?) {
with("function if real", f) {
if (f.origin == IrDeclarationOrigin.FAKE_OVERRIDE)
return
// TODO: We want to skip these, and use `.target` for
// functions, but that causes our type parameter mapping
// to go wrong and gives us IndexOutOfBoundsExceptions
// if (f.origin == IrDeclarationOrigin.FAKE_OVERRIDE)
// return
extractFunction(f, parentId, extractBody, typeSubstitution, classTypeArgsIncludingOuterClasses)
}
}
@@ -971,7 +974,11 @@ open class KotlinFileExtractor(
}
fun extractMethodAccess(syntacticCallTarget: IrFunction, extractMethodTypeArguments: Boolean = true, extractClassTypeArguments: Boolean = false) {
val callTarget = syntacticCallTarget.target
// TODO: We want to say
// callTarget = syntacticCallTarget.target
// but that causes our type parameter mapping
// to go wrong and gives us IndexOutOfBoundsExceptions
val callTarget = syntacticCallTarget // .target
val id = tw.getFreshIdLabel<DbMethodaccess>()
val type = useType(c.type)
val locId = tw.getLocation(c)