Rework test runner to avoid mutable objects. (#1702)
This commit is contained in:
+4
-4
@@ -75,7 +75,7 @@ internal class FunctionInlining(val context: Context): IrElementTransformerVoidW
|
||||
val functionDescriptor = irCall.descriptor
|
||||
if (!functionDescriptor.needsInlining) return irCall // This call does not need inlining.
|
||||
|
||||
val functionDeclaration = getFunctionDeclaration(functionDescriptor) // Get declaration of the function to be inlined.
|
||||
val functionDeclaration = getFunctionDeclaration(functionDescriptor) // Get declaration of the function to be inlined.
|
||||
if (functionDeclaration == null) { // We failed to get the declaration.
|
||||
val message = "Inliner failed to obtain function declaration: " +
|
||||
functionDescriptor.fqNameSafe.toString()
|
||||
@@ -83,9 +83,9 @@ internal class FunctionInlining(val context: Context): IrElementTransformerVoidW
|
||||
return irCall
|
||||
}
|
||||
|
||||
functionDeclaration.transformChildrenVoid(this) // Process recursive inline.
|
||||
functionDeclaration.transformChildrenVoid(this) // Process recursive inline.
|
||||
val inliner = Inliner(globalSubstituteMap, functionDeclaration, currentScope!!, context) // Create inliner for this scope.
|
||||
return inliner.inline(irCall ) // Return newly created IrInlineBody instead of IrCall.
|
||||
return inliner.inline(irCall) // Return newly created IrInlineBody instead of IrCall.
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------//
|
||||
@@ -134,7 +134,7 @@ private class Inliner(val globalSubstituteMap: MutableMap<DeclarationDescriptor,
|
||||
private fun inlineFunction(callee: IrCall, // Call to be substituted.
|
||||
caller: IrFunction): IrReturnableBlockImpl { // Function to substitute.
|
||||
|
||||
val copyFunctionDeclaration = copyIrElement.copy( // Create copy of original function.
|
||||
val copyFunctionDeclaration = copyIrElement.copy( // Create copy of original function.
|
||||
irElement = caller, // Descriptors declared inside the function will be copied.
|
||||
typeSubstitutor = createTypeSubstitutor(callee) // Type parameters will be substituted with type arguments.
|
||||
) as IrFunction
|
||||
|
||||
+4
-2
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.copyTypeArgumentsFrom
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl
|
||||
@@ -405,9 +406,10 @@ internal class TestProcessor (val context: KonanBackendContext) {
|
||||
endOffset = UNDEFINED_OFFSET,
|
||||
symbol = symbols.symbolTable.referenceConstructor(superConstructor),
|
||||
descriptor = superConstructor,
|
||||
typeArguments = mapOf(superConstructor.typeParameters[0] to testClassType,
|
||||
superConstructor.typeParameters[1] to testCompanionType)
|
||||
typeArgumentsCount = 2
|
||||
).apply {
|
||||
copyTypeArgumentsFrom(mapOf(superConstructor.typeParameters[0] to testClassType,
|
||||
superConstructor.typeParameters[1] to testCompanionType))
|
||||
putValueArgument(0, IrConstImpl.string(
|
||||
UNDEFINED_OFFSET,
|
||||
UNDEFINED_OFFSET,
|
||||
|
||||
@@ -10,5 +10,5 @@ fun test() {
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println("Custom main")
|
||||
TestRunner.run(args)
|
||||
testLauncherEntryPoint(args)
|
||||
}
|
||||
Reference in New Issue
Block a user