Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False compiler "Unused import" warning #9616

Closed
scabug opened this issue Jan 7, 2016 · 2 comments
Closed

False compiler "Unused import" warning #9616

scabug opened this issue Jan 7, 2016 · 2 comments

Comments

@scabug
Copy link

scabug commented Jan 7, 2016

Given this sbt.build and Test.scala

scalaVersion  := "2.11.7"

libraryDependencies += "org.scala-lang.modules" %% "scala-pickling" % "0.10.1"

scalacOptions += "-Ywarn-unused-import"
package foo

import scala.pickling.json._
import scala.pickling.Defaults._

case class Person(name: String, age: Int)

object UnpickleTest {
  val pkl = Person("foo", 20).pickle
  val person = pkl.unpickle[Person]
}

Running sbt compile produce:

[warn] /.../foo/Test.scala:1: Unused import
[warn] package foo
[warn] ^
[warn] one warning found

In Scala Pickling issues there is another manifestation of this here. Problem is that when compiler emit this false warning it provide reporters with parameter pos of type scala.reflect.internal.util.Position whose field point is set to -1. By my understanding this shouldn't happen in the first place at all.

Ensime Server is suffering with these false warnings also.

@scabug
Copy link
Author

scabug commented Jan 7, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9616?orig=1
Reporter: Josef Vlach (VlachJosef)
Affected Versions: 2.11.7
Duplicates #9383

@scabug
Copy link
Author

scabug commented Jan 7, 2016

@som-snytt said (edited on Jan 7, 2016 11:07:16 PM UTC):
The related issue was a false negative, which was fixed for 2.12.

I wasn't able to try the pickling sample under 2.12, so I backported that fix, which does remove the false positive but also results in a subtle error during macro expansion, probably because of using a 2.11.7 pickling against a 2.11.8 library.

scala/scala#4899

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants