@@ -131,17 +131,22 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer:
131131 cpy.ValDef (tree)(rhs = rhs)
132132
133133 case tree : DefDef =>
134- // Only transform the params (for the default values) and the rhs.
135- val paramss = transformParamss(tree.paramss)
136- val rhs = transform(tree.rhs)
137- val finalRhs =
138- if canInstrumentDefDef(tree) then
139- // Ensure that the rhs is always instrumented, if possible
140- instrumentBody(tree, rhs)
141- else
142- rhs
143- cpy.DefDef (tree)(tree.name, paramss, tree.tpt, finalRhs)
144-
134+ if tree.symbol.isOneOf(Inline | Erased ) then
135+ // Inline and erased definitions will not be in the generated code and therefore do not need to be instrumented.
136+ // Note that a retained inline method will have a `$retained` variant that will be instrumented.
137+ tree
138+ else
139+ // Only transform the params (for the default values) and the rhs.
140+ val paramss = transformParamss(tree.paramss)
141+ val rhs = transform(tree.rhs)
142+ val finalRhs =
143+ if canInstrumentDefDef(tree) then
144+ // Ensure that the rhs is always instrumented, if possible
145+ instrumentBody(tree, rhs)
146+ else
147+ rhs
148+ cpy.DefDef (tree)(tree.name, paramss, tree.tpt, finalRhs)
149+ end if
145150 case tree : PackageDef =>
146151 // only transform the statements of the package
147152 cpy.PackageDef (tree)(tree.pid, transform(tree.stats))
@@ -330,4 +335,4 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer:
330335
331336object InstrumentCoverage :
332337 val name : String = " instrumentCoverage"
333- val description : String = " instrument code for coverage cheking "
338+ val description : String = " instrument code for coverage checking "
0 commit comments