[KTIJ-21963] Move reflective access after default args lowerings

This commit is contained in:
Kristoffer Andersen
2022-06-15 19:13:19 +02:00
committed by Alexander Udalov
parent 9b402a42c7
commit 63f108b350
2 changed files with 7 additions and 6 deletions
@@ -167,7 +167,7 @@ private val defaultArgumentStubPhase = makeIrFilePhase(
prerequisite = setOf(localDeclarationsPhase) prerequisite = setOf(localDeclarationsPhase)
) )
private val defaultArgumentCleanerPhase = makeIrFilePhase( val defaultArgumentCleanerPhase = makeIrFilePhase(
{ context: JvmBackendContext -> DefaultParameterCleaner(context, replaceDefaultValuesWithStubs = true) }, { context: JvmBackendContext -> DefaultParameterCleaner(context, replaceDefaultValuesWithStubs = true) },
name = "DefaultParameterCleaner", name = "DefaultParameterCleaner",
description = "Replace default values arguments with stubs", description = "Replace default values arguments with stubs",
@@ -424,13 +424,13 @@ private fun buildLoweringsPhase(
val jvmFragmentLoweringPhases = run { val jvmFragmentLoweringPhases = run {
val localDeclarationsIndex = jvmFilePhases.indexOf(localDeclarationsPhase) val defaultArgsPhase = jvmFilePhases.indexOf(defaultArgumentCleanerPhase)
val loweringsUpToLocalDeclarations = jvmFilePhases.subList(0, localDeclarationsIndex + 1) val loweringsUpToAndIncludingDefaultArgsPhase = jvmFilePhases.subList(0, defaultArgsPhase + 1)
val remainingLowerings = jvmFilePhases.subList(localDeclarationsIndex + 1, jvmFilePhases.size) val remainingLowerings = jvmFilePhases.subList(defaultArgsPhase + 1, jvmFilePhases.size)
buildJvmLoweringPhases( buildJvmLoweringPhases(
"IrFragmentLowering", "IrFragmentLowering",
listOf( listOf(
"PrefixOfIRPhases" to loweringsUpToLocalDeclarations, "PrefixOfIRPhases" to loweringsUpToAndIncludingDefaultArgsPhase,
"FragmentLowerings" to listOf( "FragmentLowerings" to listOf(
fragmentLocalFunctionPatchLowering, fragmentLocalFunctionPatchLowering,
reflectiveAccessLowering, reflectiveAccessLowering,
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.backend.common.FileLoweringPass
import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
import org.jetbrains.kotlin.backend.jvm.defaultArgumentCleanerPhase
import org.jetbrains.kotlin.backend.jvm.ir.* import org.jetbrains.kotlin.backend.jvm.ir.*
import org.jetbrains.kotlin.backend.jvm.lower.SyntheticAccessorLowering.Companion.isAccessible import org.jetbrains.kotlin.backend.jvm.lower.SyntheticAccessorLowering.Companion.isAccessible
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
@@ -30,7 +31,7 @@ val reflectiveAccessLowering = makeIrFilePhase(
::ReflectiveAccessLowering, ::ReflectiveAccessLowering,
name = "ReflectiveCalls", name = "ReflectiveCalls",
description = "Avoid the need for accessors by replacing direct access to inaccessible members with accesses via reflection", description = "Avoid the need for accessors by replacing direct access to inaccessible members with accesses via reflection",
prerequisite = setOf() prerequisite = setOf(defaultArgumentCleanerPhase)
) )
// This lowering replaces member accesses that are illegal according to JVM // This lowering replaces member accesses that are illegal according to JVM