Skip to content

Commit 412412c

Browse files
committed
No -Wunused:imports for language imports
1 parent 6d8d20d commit 412412c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class CheckUnused extends Phase:
3535
override def description: String = CheckUnused.description
3636

3737
override def isRunnable(using Context): Boolean =
38-
ctx.settings.Wunused.value.nonEmpty
38+
ctx.settings.Wunused.value.nonEmpty &&
39+
!ctx.isJava
3940

4041
override def run(using Context): Unit =
4142
val tree = ctx.compilationUnit.tpdTree
@@ -179,8 +180,9 @@ object CheckUnused:
179180

180181
/** Register an import */
181182
def registerImport(imp: tpd.Import)(using Context): Unit =
182-
impInScope.top += imp
183-
unusedImport ++= imp.selectors.filter(s => !isImportExclusion(s))
183+
if !tpd.languageImport(imp.expr).nonEmpty then
184+
impInScope.top += imp
185+
unusedImport ++= imp.selectors.filter(s => !isImportExclusion(s))
184186

185187
def registerDef(valOrDef: tpd.ValOrDefDef)(using Context): Unit =
186188
if valOrDef.symbol.is(Param) then

0 commit comments

Comments
 (0)