From 07f10794af7dd5e1ee8d2225ae57b291ffce1c77 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov <138671+Godin@users.noreply.github.com> Date: Mon, 22 Jul 2019 12:22:07 +0200 Subject: [PATCH] KotlinDefaultArgumentsFilter should not assume that all parameters consume one slot (#908) --- .../targets/KotlinDefaultArgumentsTarget.kt | 6 ++++ .../KotlinDefaultArgumentsFilterTest.java | 34 +++++++++++++++++++ .../filter/KotlinDefaultArgumentsFilter.java | 19 +++++++++-- org.jacoco.doc/docroot/doc/changes.html | 4 +++ 4 files changed, 61 insertions(+), 2 deletions(-) diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDefaultArgumentsTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDefaultArgumentsTarget.kt index 1a89eaba36..210cc8e917 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDefaultArgumentsTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDefaultArgumentsTarget.kt @@ -19,6 +19,9 @@ object KotlinDefaultArgumentsTarget { private fun f(a: String = "a", b: String = "b") { // assertFullyCovered(0, 0) } + private fun longParameter(x: Long = 0) { // assertFullyCovered() + } + private fun branch(a: Boolean, b: String = if (a) "a" else "b") { // assertFullyCovered(0, 2) } @@ -38,6 +41,9 @@ object KotlinDefaultArgumentsTarget { /* next invocation doesn't use synthetic method: */ f("a", "b") + longParameter() + longParameter(1) + branch(false) branch(true) diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilterTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilterTest.java index 721abfb029..d649e8e072 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilterTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilterTest.java @@ -184,4 +184,38 @@ public void should_filter_constructors() { assertIgnored(new Range(m.instructions.get(3), m.instructions.get(3))); } + /** + *
+ * data class C(val x: Long = 42) + *+ */ + @Test + public void should_filter_methods_with_parameters_that_consume_two_slots() { + final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION, + Opcodes.ACC_SYNTHETIC, "
long
or double
+ should be filtered out during generation of report
+ (GitHub #908).