File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -433,6 +433,7 @@ object CheckUnused:
433433 if inliners == 0
434434 && languageImport(imp.expr).isEmpty
435435 && ! imp.isGeneratedByEnum
436+ && ! imp.isCompiletimeTesting
436437 && ! ctx.owner.name.isReplWrapperName
437438 then
438439 imps.put(imp, ())
@@ -990,6 +991,10 @@ object CheckUnused:
990991 then imp.expr.tpe.allMembers.exists(_.symbol.isCanEqual)
991992 else imp.expr.tpe.member(sel.name.toTermName).hasAltWith(_.symbol.isCanEqual)
992993
994+ /** No mechanism for detection yet. */
995+ def isCompiletimeTesting : Boolean =
996+ imp.expr.symbol == defn.CompiletimeTestingPackage // .moduleClass
997+
993998 extension (pos : SrcPos )
994999 def isZeroExtentSynthetic : Boolean = pos.span.isSynthetic && pos.span.isZeroExtent
9951000 def isSynthetic : Boolean = pos.span.isSynthetic && pos.span.exists
Original file line number Diff line number Diff line change 1+ //> using options -Wunused:imports
2+
3+ def i23967 : Boolean = {
4+ // import scala.compiletime.testing.typeCheckErrors
5+ import scala .compiletime .testing .* // nowarn
6+ typeChecks(" 2 + 2" )
7+ }
8+
9+ package p:
10+ val code = """ "hello, world""""
11+ package c:
12+ class C (i : Int )
13+
14+ package q:
15+ import c .* // warn should be nowarn
16+ import p .* // warn should be nowarn
17+ import scala .compiletime .testing .*
18+ def test () = typeCheckErrors(""" println(C("hello, world"))""" )
19+ def ok () = typeChecks(" println(code)" )
20+ inline def f (inline i : Int ) = 42 + i
21+
22+ package i23967b:
23+ package ok:
24+ import scala .compiletime .testing .* // nowarn
25+ def test () = typeChecks(" 42 + 27" )
26+ package nok:
27+ import scala .compiletime .testing .typeChecks // nowarn
28+ def test () = typeChecks(" 42 + 27" )
29+
30+ @ main def Test = println :
31+ q.f(27 )
You can’t perform that action at this time.
0 commit comments