Get project passing unit tests with Kotlin 1.4
This commit is contained in:
+1
-2
@@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
kotlin("jvm") version "1.4-M2" apply false
|
||||
kotlin("jvm") version "1.4.0" apply false
|
||||
id("org.jetbrains.dokka") version "0.10.0" apply false
|
||||
id("com.gradle.plugin-publish") version "0.11.0" apply false
|
||||
}
|
||||
@@ -13,6 +13,5 @@ subprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,14 @@
|
||||
|
||||
package com.bnorm.power
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.deepCopyWithVariables
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
import org.jetbrains.kotlin.ir.expressions.IrCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConst
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||
import org.jetbrains.kotlin.ir.expressions.IrWhen
|
||||
import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
|
||||
sealed class Node {
|
||||
@@ -67,10 +68,10 @@ class ExpressionNode(
|
||||
_expressions.add(expression)
|
||||
}
|
||||
|
||||
fun getExpressionsCopy(): List<IrExpression> {
|
||||
fun getExpressionsCopy(initialParent: IrDeclarationParent?): List<IrExpression> {
|
||||
// Return a copy of all the expression by creating a deep copy of the head
|
||||
// expression and running back through the assertion tree builder
|
||||
val headCopy = _expressions.first().deepCopyWithVariables()
|
||||
val headCopy = _expressions.first().deepCopyWithSymbols(initialParent)
|
||||
return (buildAssertTree(headCopy).children.single() as ExpressionNode)._expressions
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +167,7 @@ class PowerAssertCallTransformer(
|
||||
isStringFunction(parameters[1].type) -> {
|
||||
object : FunctionDelegate {
|
||||
override fun buildCall(builder: IrBuilderWithScope, message: IrExpression): IrExpression = with(builder) {
|
||||
val scope = this
|
||||
val lambda = buildFun {
|
||||
name = Name.special("<anonymous>")
|
||||
returnType = context.irBuiltIns.stringType
|
||||
@@ -177,6 +178,7 @@ class PowerAssertCallTransformer(
|
||||
body = bodyBuilder.irBlockBody {
|
||||
+irReturn(message)
|
||||
}
|
||||
parent = scope.parent
|
||||
}
|
||||
val expression = IrFunctionExpressionImpl(-1, -1, context.irBuiltIns.stringType, lambda, IrStatementOrigin.LAMBDA)
|
||||
irCall(overload, type = overload.descriptor.returnType!!.toIrType()).apply {
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.ir.builders.IrStatementsBuilder
|
||||
import org.jetbrains.kotlin.ir.builders.irBlock
|
||||
import org.jetbrains.kotlin.ir.builders.irGet
|
||||
import org.jetbrains.kotlin.ir.builders.irTemporary
|
||||
import org.jetbrains.kotlin.ir.builders.parent
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrGetValue
|
||||
import org.jetbrains.kotlin.ir.expressions.IrWhen
|
||||
@@ -75,13 +76,13 @@ abstract class PowerAssertGenerator {
|
||||
node: ExpressionNode,
|
||||
thenPart: IrStatementsBuilder<*>.(subStack: MutableList<IrStackVariable>) -> IrExpression
|
||||
): IrWhen {
|
||||
val expressions = node.getExpressionsCopy()
|
||||
val expressions = node.getExpressionsCopy(this.parent)
|
||||
val stackTransformer = StackBuilder(this, stack, expressions)
|
||||
val transformed = expressions.first().transform(stackTransformer, null)
|
||||
return irIfThen(irNot(transformed), thenPart(stack.toMutableList()))
|
||||
}
|
||||
|
||||
inner class StackBuilder(
|
||||
class StackBuilder(
|
||||
private val builder: IrStatementsBuilder<*>,
|
||||
private val stack: MutableList<IrStackVariable>,
|
||||
private val transform: List<IrExpression>
|
||||
|
||||
Reference in New Issue
Block a user