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