Skip to content

Commit 3736e85

Browse files
Fix the issue with coverage that was caused by information being lost with a TypeApply
1 parent 473cf25 commit 3736e85

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

compiler/src/dotty/tools/dotc/transform/InstrumentCoverage.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer:
237237
val InstrumentedParts(pre, coverageCall, expr) = tryInstrument(fun)
238238

239239
if coverageCall.isEmpty then
240-
// `fun` cannot be instrumented, and `args` is a type so we keep this tree as it is
241-
tree
240+
// `fun` cannot be instrumented, and `args` is a type but the expr may have been transformed
241+
cpy.TypeApply(tree)(expr, args)
242242
else
243243
// expr[T] shouldn't be transformed to:
244244
// {invoked(...), expr}[T]
@@ -330,7 +330,7 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer:
330330
tree.rhs
331331
else if sym.isClassConstructor then
332332
instrumentSecondaryCtor(tree)
333-
else if !sym.isOneOf(Accessor | Artifact | Synthetic) then
333+
else if !sym.isOneOf(Accessor) then
334334
// If the body can be instrumented, do it (i.e. insert a "coverage call" at the beginning)
335335
// This is useful because methods can be stored and called later, or called by reflection,
336336
// and if the rhs is too simple to be instrumented (like `def f = this`),

tests/pos-with-compiler-cc/dotc/transform/InstrumentCoverage.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer:
236236
val InstrumentedParts(pre, coverageCall, expr) = tryInstrument(fun)
237237

238238
if coverageCall.isEmpty then
239-
// `fun` cannot be instrumented, and `args` is a type so we keep this tree as it is
240-
tree
239+
// `fun` cannot be instrumented, and `args` is a type but the expr may have been transformed
240+
cpy.TypeApply(tree)(expr, args)
241241
else
242242
// expr[T] shouldn't be transformed to:
243243
// {invoked(...), expr}[T]

0 commit comments

Comments
 (0)