JVM IR: substitute generic type for inline class replacement function calls

The main change here is in `JvmInlineClassLowering.visitFunctionAccess`,
where we now store the substituted return type of the function as the
type of the call expression. Without it, the call could have a
meaningless type, e.g. some `T` which is inaccessible at that place, and
that could backfire in subsequent lowerings in codegen. For example, in
the `stringPlus.kt` test, it would prevent the code in
`FlattenStringConcatenationLowering.isStringPlusCall` from recognizing
and replacing the `String.plus` call, leading to a codegen exception.

Other changes are mostly cosmetics to make the code similar to
`visitFunctionReference`, and preventive optimizations for the case when
the substitution map is empty.
This commit is contained in:
Alexander Udalov
2020-10-26 19:08:00 +01:00
parent 4a3a2ef72a
commit ad5b6da273
17 changed files with 73 additions and 37 deletions
@@ -1,8 +1,4 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND_MULTI_MODULE: JVM_IR, JVM_MULTI_MODULE_IR_AGAINST_OLD
// FILE: inline.kt
inline class IC(val value: String) {
@@ -43,4 +39,4 @@ fun box(): String {
if (res != "OK") return "FAIL 3: $res"
return "OK"
}
}