diff --git a/kotlin-power-assert-plugin/src/main/kotlin/com/bnorm/power/PowerAssertCallTransformer.kt b/kotlin-power-assert-plugin/src/main/kotlin/com/bnorm/power/PowerAssertCallTransformer.kt index f3a5ebdb8fb..e9367f5c037 100644 --- a/kotlin-power-assert-plugin/src/main/kotlin/com/bnorm/power/PowerAssertCallTransformer.kt +++ b/kotlin-power-assert-plugin/src/main/kotlin/com/bnorm/power/PowerAssertCallTransformer.kt @@ -229,11 +229,11 @@ class PowerAssertCallTransformer( private fun isStringSupertype(type: IrType): Boolean = context.irBuiltIns.stringType.isSubtypeOf(type, context.irBuiltIns) - private fun IrType.isAssignableTo(type: IrType): Boolean = - isSubtypeOf(type, context.irBuiltIns) || - ((type.classifierOrNull as? IrTypeParameterSymbol)?.owner?.superTypes?.all { - isSubtypeOf(it, context.irBuiltIns) - } ?: false) + private fun IrType.isAssignableTo(type: IrType): Boolean { + if (isSubtypeOf(type, context.irBuiltIns)) return true + val superTypes = (type.classifierOrNull as? IrTypeParameterSymbol)?.owner?.superTypes + return superTypes != null && superTypes.all { isSubtypeOf(it, context.irBuiltIns) } + } private fun MessageCollector.info(expression: IrElement, message: String) { report(expression, CompilerMessageSeverity.INFO, message) diff --git a/kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/AssertBooleanTest.kt b/kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/AssertBooleanTest.kt index 786287f45d0..ade3f26a4de 100644 --- a/kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/AssertBooleanTest.kt +++ b/kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/AssertBooleanTest.kt @@ -2,24 +2,23 @@ package com.bnorm.power import org.jetbrains.kotlin.name.FqName import org.junit.Test -import kotlin.test.assertEquals class AssertBooleanTest { @Test fun `test assertTrue transformation`() { assertMessage( """ -import kotlin.test.assertTrue - -fun main() { - assertTrue(1 != 1) -}""", + import kotlin.test.assertTrue + + fun main() { + assertTrue(1 != 1) + }""", """ -Assertion failed -assertTrue(1 != 1) - | - false -""".trimIndent(), + Assertion failed + assertTrue(1 != 1) + | + false + """.trimIndent(), PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertTrue"))) ) } @@ -28,17 +27,17 @@ assertTrue(1 != 1) fun `test assertFalse transformation`() { assertMessage( """ -import kotlin.test.assertFalse - -fun main() { - assertFalse(1 == 1) -}""", + import kotlin.test.assertFalse + + fun main() { + assertFalse(1 == 1) + }""", """ -Assertion failed -assertFalse(1 == 1) - | - true -""".trimIndent(), + Assertion failed + assertFalse(1 == 1) + | + true + """.trimIndent(), PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertFalse"))) ) } diff --git a/kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/DebugFunctionTest.kt b/kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/DebugFunctionTest.kt index 34edaa0d940..b77dad7cb41 100644 --- a/kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/DebugFunctionTest.kt +++ b/kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/DebugFunctionTest.kt @@ -12,9 +12,11 @@ import kotlin.test.assertEquals class DebugFunctionTest { @Test fun `debug function transformation`() { - val actual = executeMainDebug(""" + val actual = executeMainDebug( + """ dbg(1 + 2 + 3) - """.trimIndent()) + """.trimIndent() + ) assertEquals( """ dbg(1 + 2 + 3) @@ -27,9 +29,11 @@ class DebugFunctionTest { } @Test fun `debug function transformation with message`() { - val actual = executeMainDebug(""" + val actual = executeMainDebug( + """ dbg(1 + 2 + 3, "Message:") - """.trimIndent()) + """.trimIndent() + ) assertEquals( """ Message: diff --git a/sample/src/commonTest/kotlin/com/bnorm/power/PowerAssertTest.kt b/sample/src/commonTest/kotlin/com/bnorm/power/PowerAssertTest.kt index 8e374f9396e..c0231ff33de 100644 --- a/sample/src/commonTest/kotlin/com/bnorm/power/PowerAssertTest.kt +++ b/sample/src/commonTest/kotlin/com/bnorm/power/PowerAssertTest.kt @@ -130,7 +130,8 @@ class PowerAssertTest { | | | Jane Hello, Jane - """.trimIndent()) + """.trimIndent() + ) } @Test @@ -146,6 +147,7 @@ class PowerAssertTest { | | | Jane Hello, Jane - """.trimIndent()) + """.trimIndent() + ) } }