[KAPT] Don't fail on empty InsnList

Fix failing on empty methods inline methods (after light generation)

#KT-45032 Fixed
This commit is contained in:
Andrey Zinovyev
2021-03-10 10:58:35 +03:00
committed by GitHub
parent 02b5b931d4
commit 7edbf79b4b
4 changed files with 38 additions and 2 deletions
@@ -61,7 +61,7 @@ class InsnSequence(val from: AbstractInsnNode, val to: AbstractInsnNode?) : Sequ
}
}
fun InsnList.asSequence() = InsnSequence(this)
fun InsnList.asSequence(): Sequence<AbstractInsnNode> = if (size() == 0) emptySequence() else InsnSequence(this)
fun MethodNode.prepareForEmitting() {
stripOptimizationMarkers()
@@ -287,6 +287,22 @@ open class KaptIncrementalIT : BaseGradleIT() {
}
}
@Test
fun testChangeInlineDelegate() {
val project = getProject()
project.build("build") {
assertSuccessful()
}
val file = project.projectDir.getFileByName("Usage.kt")
file.modify { "$it//" }
project.build("build") {
assertSuccessful()
assertTasksExecuted(":kaptGenerateStubsKotlin", ":compileKotlin")
}
}
private fun CompiledProject.assertCompiledKotlinSourcesHandleKapt3(
sources: Iterable<String>,
weakTesting: Boolean = false
@@ -319,4 +335,4 @@ open class KaptIncrementalIT : BaseGradleIT() {
val names = annotatedElementNames.map { it.capitalize() + "Generated" }
return names.map { it + ".java" }
}
}
}
@@ -0,0 +1,13 @@
package delegate
import kotlin.reflect.KProperty
class Delegate() {
inline operator fun getValue(thisRef: Any?, property: KProperty<*>): String {
return "I'm your val"
}
inline operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) {
println("$value has been assigned to '${property.name}' in $thisRef.")
}
}
@@ -0,0 +1,7 @@
package delegate
object Usage {
var delegated: String by Delegate()
}