-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
-Wunused:all
and nested type class derivation
#16679
Comments
Thanks for reporting all this
Can you give me a code example of this. It would help me a lot debuging this. I do not really understand what you meant here. |
Just that this does not give a warning where there is no subtype. object myPackage:
trait CaseClassName[A]:
def name: String
object CaseClassName:
import scala.deriving.Mirror
inline final def derived[A](using inline A: Mirror.Of[A]): CaseClassName[A] =
new CaseClassName[A]:
def name: String = A.toString
import myPackage.CaseClassName
case class CoolClass(i: Int) derives CaseClassName
println(summon[myPackage.CaseClassName[CoolClass]].name) But I see now that its not really that relevant. This also fails, so its more about More minimizedWith this setup object myPackage:
object Foo:
trait CaseClassName[A]:
def name: String
object CaseClassName:
inline final def derived[A](using inline A: scala.deriving.Mirror.Of[A]): CaseClassName[A] =
new CaseClassName[A]:
def name: String = A.toString This fails import myPackage.Foo
case class CoolClass(i: Int) derives Foo.CaseClassName
println(summon[Foo.CaseClassName[CoolClass]].name) But this works import myPackage.Foo.CaseClassName
case class CoolClass(i: Int) derives CaseClassName
println(summon[CaseClassName[CoolClass]].name) |
Nested term selection is not required to be after package example
import io.circe.Encoder.{AsObject => ToJson}
case class Foo(bar: String, baz: Int) derives ToJson
|
Aha, my minimised example picked it up as used since it was used in the |
Disclaimer: I'm not an expert here but just a curious dotty user impatient to
I'm not sure if CheckUnused is a right place to explicitly traverse |
@ivan-klass thank you for your observations, I am looking into it right now. |
The reason behind this issue was the way the Idents were generated in the derived code. If you wrote: object Foo:
object Bar
Foo.Bar Then, Idents for |
I tried adding the new unused flag (from #16157) to my work codebase and was surprised that it warned about unused import when used with the json library
circe
s derivation of json Encoders from case classes. (case class Foo(i: Int) derives Encoder.AsObject
). A minimal reproducer independent of circe is below. I see no error when trying to derive the "top level" typeclass and not a subtype.Compiler version
With nightly:
3.3.0-RC1-bin-20230112-be10bc6-NIGHTLY
Minimized code
Output
Expectation
The import is needed and used 2 places (at the summon and at the derives), so no warn should be provided.
The text was updated successfully, but these errors were encountered: