From fd90e3ee3404d4996f42fa95eef32c45464592bb Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Fri, 28 Dec 2018 00:11:45 +0100 Subject: synthetic methods that represent Kotlin suspend functions should not be ignored (#804) --- .../internal/analysis/filter/KotlinCoroutineFilter.java | 8 ++++++++ .../core/internal/analysis/filter/SyntheticFilter.java | 13 +++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'org.jacoco.core/src/org/jacoco/core/internal') diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinCoroutineFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinCoroutineFilter.java index f1261b22..d9944bf5 100644 --- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinCoroutineFilter.java +++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinCoroutineFilter.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.List; import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.JumpInsnNode; import org.objectweb.asm.tree.LdcInsnNode; @@ -26,6 +27,13 @@ import org.objectweb.asm.tree.TableSwitchInsnNode; */ public final class KotlinCoroutineFilter implements IFilter { + static boolean isLastArgumentContinuation(final MethodNode methodNode) { + final Type methodType = Type.getMethodType(methodNode.desc); + final int lastArgument = methodType.getArgumentTypes().length - 1; + return lastArgument >= 0 && "kotlin.coroutines.Continuation".equals( + methodType.getArgumentTypes()[lastArgument].getClassName()); + } + public void filter(final MethodNode methodNode, final IFilterContext context, final IFilterOutput output) { diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/SyntheticFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/SyntheticFilter.java index 5dfeecf5..34a66b18 100644 --- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/SyntheticFilter.java +++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/SyntheticFilter.java @@ -29,10 +29,15 @@ public final class SyntheticFilter implements IFilter { return; } - if (KotlinDefaultArgumentsFilter - .isDefaultArgumentsMethodName(methodNode.name) - && KotlinGeneratedFilter.isKotlinClass(context)) { - return; + if (KotlinGeneratedFilter.isKotlinClass(context)) { + if (KotlinDefaultArgumentsFilter + .isDefaultArgumentsMethodName(methodNode.name)) { + return; + } + + if (KotlinCoroutineFilter.isLastArgumentContinuation(methodNode)) { + return; + } } output.ignore(methodNode.instructions.getFirst(), -- cgit v1.2.3