Skip to content

Instantly share code, notes, and snippets.

@majk-p
Created January 9, 2025 14:28
Show Gist options
  • Select an option

  • Save majk-p/9d6dfffce77688c835ddd148fcc3af77 to your computer and use it in GitHub Desktop.

Select an option

Save majk-p/9d6dfffce77688c835ddd148fcc3af77 to your computer and use it in GitHub Desktop.
Weird behavior of -Ywarn-unused:privates

This is an example of weird behavior of -Ywarn-unused:privates with Scala 2.12.

The lib is a private object within example package. Even though lib.doStuff method is invoked in main class, the -Ywarn-unused:privates would mark it as unused. Combined with fatal warnings this breaks compilation for no reason.

package example
private object lib {
def doStuff = println("Hello from MyLib")
}
//> using scala "2.12.20"
//> using option "-Ywarn-unused:privates"
package example
object Main extends App {
println("Hello world")
lib.doStuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment