@@ -475,7 +475,10 @@ object CheckUnused:
475475 && ! imp.isGeneratedByEnum
476476 && ! ctx.owner.name.isReplWrapperName
477477 then
478- imps.put(imp, ())
478+ if imp.isCompiletimeTesting then
479+ isNullified = true
480+ else
481+ imps.put(imp, ())
479482 case tree : Bind =>
480483 if ! tree.name.isInstanceOf [DerivedName ] && ! tree.name.is(WildcardParamName ) then
481484 if tree.hasAttachment(NoWarn ) then
@@ -505,6 +508,9 @@ object CheckUnused:
505508 asss.addOne(sym)
506509 else
507510 refs.addOne(sym)
511+
512+ // currently compiletime.testing is completely erased, so ignore the unit
513+ var isNullified = false
508514 end RefInfos
509515
510516 // Names are resolved by definitions and imports, which have four precedence levels:
@@ -519,7 +525,7 @@ object CheckUnused:
519525 inline def weakerThan (q : Precedence ): Boolean = p > q
520526 inline def isNone : Boolean = p == NoPrecedence
521527
522- def reportUnused ()(using Context ): Unit =
528+ def reportUnused ()(using Context ): Unit = if ! refInfos.isNullified then
523529 for (msg, pos, origin) <- warnings do
524530 if origin.isEmpty then report.warning(msg, pos)
525531 else report.warning(msg, pos, origin)
@@ -1003,6 +1009,10 @@ object CheckUnused:
10031009 def isGeneratedByEnum : Boolean =
10041010 imp.symbol.exists && imp.symbol.owner.is(Enum , butNot = Case )
10051011
1012+ /** No mechanism for detection yet. */
1013+ def isCompiletimeTesting : Boolean =
1014+ imp.expr.symbol == defn.CompiletimeTestingPackage // .moduleClass
1015+
10061016 extension (pos : SrcPos )
10071017 def isZeroExtentSynthetic : Boolean = pos.span.isSynthetic && pos.span.isZeroExtent
10081018 def isSynthetic : Boolean = pos.span.isSynthetic && pos.span.exists
0 commit comments