@@ -171,4 +171,48 @@ public void should_not_filter_hand_written_serializer_method() {
171171 assertIgnored (m );
172172 }
173173
174+ /**
175+ * <pre>
176+ * @kotlinx.serialization.Serializable // line 1
177+ * enum class Example {
178+ * V
179+ * }
180+ * </pre>
181+ *
182+ * <pre>
183+ * @kotlinx.serialization.Serializable // line 1
184+ * sealed class Example {
185+ * }
186+ * </pre>
187+ */
188+ @ Test
189+ public void should_filter_generated_serializer_method_in_companions_of_enum_and_sealed_class () {
190+ context .className = "Example$Companion" ;
191+
192+ final MethodNode initMethod = new MethodNode (Opcodes .ACC_PRIVATE ,
193+ "<init>" , "()V" , null , null );
194+ final Label initMethodLineNumberLabel = new Label ();
195+ initMethod .visitLabel (initMethodLineNumberLabel );
196+ initMethod .visitLineNumber (1 , initMethodLineNumberLabel );
197+ filter .filter (initMethod , context , output );
198+
199+ final MethodNode m = new MethodNode (
200+ Opcodes .ACC_PUBLIC | Opcodes .ACC_FINAL , "serializer" ,
201+ "()Lkotlinx/serialization/KSerializer;" ,
202+ "()Lkotlinx/serialization/KSerializer<LExample;>;" , null );
203+ final Label label0 = new Label ();
204+ m .visitLabel (label0 );
205+ m .visitLineNumber (1 , label0 );
206+ m .visitVarInsn (Opcodes .ALOAD , 0 );
207+ m .visitMethodInsn (Opcodes .INVOKESPECIAL , "Example$Companion" ,
208+ "get$cachedSerializer" , "()Lkotlinx/serialization/KSerializer;" ,
209+ false );
210+ m .visitInsn (Opcodes .ARETURN );
211+
212+ filter .filter (m , context , output );
213+
214+ // FIXME https://github.com/jacoco/jacoco/issues/1971
215+ assertIgnored (m );
216+ }
217+
174218}
0 commit comments