You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This only happens if UNUSED.A is an alias for USED.A, it doesn't seem to happen in any other case, even if they are otherwise identical case classes
It only seems to happen for types, not values
private[scope] doesn't seem to affect the bug
importing in the other order patches the issue as expected
import USED.A explicitly fixes the issue
import UNUSED.{everything except A} fixes the issue (as you would expect)
This is quite a common pattern in our projects where we have privately aliased code in their original packages in order to skip painful re-imports in hundreds of files when moving code around to other packages.
This is quite unfortunate as none of the patches where it works are really applicable in general. If we upgraded we'd spend so much time unpicking imports and fighting automatic linting
Bug not observed on 3.7.0
(EDIT: Fixed typo in the script Test1 => USED)
The text was updated successfully, but these errors were encountered:
jdrphillips
changed the title
Incorrect unused import warnings in some cases
Incorrect unused import warnings in some cases - private definitions escaping their scope
Jun 10, 2025
Thanks for the thorough notes. Per the bullet point, the symptom happens for
//> using options -Wunused:all -Werror
object USED {
case class A(value: Int)
}
object Test1 {
class A
}
object UNUSED {
// In reality UNUSED would contain several other necessary members!
//private type A = Int //Test1.A
//private type A = Test1.A
private type A = USED.A
class B
}
object Test {
import USED.*
import UNUSED.*
def foo(a: A): Int = a.value
def g(b: B) = ()
}
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
3.7.1
Minimized code
Output
Expectation
Some notes:
UNUSED.A
is an alias forUSED.A
, it doesn't seem to happen in any other case, even if they are otherwise identical case classesprivate[scope]
doesn't seem to affect the bugimport USED.A
explicitly fixes the issueimport UNUSED.{everything except A}
fixes the issue (as you would expect)This is quite a common pattern in our projects where we have privately aliased code in their original packages in order to skip painful re-imports in hundreds of files when moving code around to other packages.
This is quite unfortunate as none of the patches where it works are really applicable in general. If we upgraded we'd spend so much time unpicking imports and fighting automatic linting
Bug not observed on 3.7.0
(EDIT: Fixed typo in the script
Test1
=>USED
)The text was updated successfully, but these errors were encountered: