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 021add49ee..affc39bc79 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 void should_not_filter_synthetic_constructor_containing_default_arguments assertIgnored(); } + /** + * For private suspending function Kotlin compiler versions prior to 1.5 + * produce package-local synthetic method that should not be filtered + * + *
+	 * private suspend fun example() {
+	 * }
+	 * 
+ * + * @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 void should_not_filter_synthetic_methods_whose_last_argument_is_kotlin_co 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 + * + *
+	 * private suspend fun example() {
+	 * }
+	 * 
+ * + * @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); + } + }