diff options
author | Evgeny Mandrikov <138671+Godin@users.noreply.github.com> | 2021-04-13 07:02:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-13 07:02:27 +0200 |
commit | 86dc5fd9f0531927054ba06991c6ee94c8da7785 (patch) | |
tree | a215dfdbd64281136e4d7504a7846e78678ed243 /org.jacoco.core.test/src | |
parent | b68fe1a0a7fb86f12cda689ec473fd6633699b55 (diff) | |
download | jacoco-86dc5fd9f0531927054ba06991c6ee94c8da7785.tar.gz |
Update filter for Kotlin 1.5 suspending functions (#1174)
Diffstat (limited to 'org.jacoco.core.test/src')
-rw-r--r-- | org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/SyntheticFilterTest.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/SyntheticFilterTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/SyntheticFilterTest.java index 021add49..affc39bc 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/SyntheticFilterTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/SyntheticFilterTest.java @@ -130,6 +130,17 @@ public class SyntheticFilterTest extends FilterTestBase { assertIgnored(); } + /** + * For private suspending function Kotlin compiler versions prior to 1.5 + * produce package-local synthetic method that should not be filtered + * + * <pre> + * private suspend fun example() { + * } + * </pre> + * + * @see #should_filter_synthetic_methods_whose_name_starts_with_access_dollar_even_if_last_argument_is_kotlin_coroutine_continuation() + */ @Test public void should_not_filter_synthetic_methods_whose_last_argument_is_kotlin_coroutine_continuation() { final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION, @@ -145,4 +156,36 @@ public class SyntheticFilterTest extends FilterTestBase { assertIgnored(); } + /** + * For private suspending function Kotlin compiler versions starting from + * 1.5 produce additional public synthetic method with name starting with + * "access$" that should be filtered + * + * <pre> + * private suspend fun example() { + * } + * </pre> + * + * @see #should_not_filter_synthetic_methods_whose_last_argument_is_kotlin_coroutine_continuation() + */ + @Test + public void should_filter_synthetic_methods_whose_name_starts_with_access_dollar_even_if_last_argument_is_kotlin_coroutine_continuation() { + final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION, + Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL + | Opcodes.ACC_SYNTHETIC, + "access$example", + "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", null, + null); + context.classAnnotations + .add(KotlinGeneratedFilter.KOTLIN_METADATA_DESC); + m.visitVarInsn(Opcodes.ALOAD, 0); + m.visitMethodInsn(Opcodes.INVOKESTATIC, "ExampleKt", "example", + "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", false); + m.visitInsn(Opcodes.RETURN); + + filter.filter(m, context, output); + + assertMethodIgnored(m); + } + } |