Skip to content

Commit 1ab427b

Browse files
Exclude methods of scala.compiletime from coverage instrumentation
1 parent fa93159 commit 1ab427b

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,11 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer:
344344
*/
345345
private def isCompilerIntrinsicMethod(sym: Symbol)(using Context): Boolean =
346346
val owner = sym.maybeOwner
347-
owner.eq(defn.AnyClass) || owner.isPrimitiveValueClass
347+
owner.exists && (
348+
owner.eq(defn.AnyClass) ||
349+
owner.isPrimitiveValueClass ||
350+
owner.maybeOwner == defn.CompiletimePackageClass
351+
)
348352

349353
object InstrumentCoverage:
350354
val name: String = "instrumentCoverage"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package covtest
2+
3+
import scala.compiletime.uninitialized
4+
class Foo:
5+
var x: AnyRef = uninitialized
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Coverage data, format version: 3.0
2+
# Statement data:
3+
# - id
4+
# - source path
5+
# - package name
6+
# - class name
7+
# - class type (Class, Object or Trait)
8+
# - full class name
9+
# - method name
10+
# - start offset
11+
# - end offset
12+
# - line number
13+
# - symbol name
14+
# - tree name
15+
# - is branch
16+
# - invocations count
17+
# - is ignored
18+
# - description (can be multi-line)
19+
# ' ' sign
20+
# ------------------------------------------

0 commit comments

Comments
 (0)