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

macros-generated private field forwardReader never has usages #641

Closed
vn971 opened this issue Apr 5, 2017 · 5 comments
Closed

macros-generated private field forwardReader never has usages #641

vn971 opened this issue Apr 5, 2017 · 5 comments

Comments

@vn971
Copy link

vn971 commented Apr 5, 2017

Hi. The current implementation of Macros.handler, Macros.reader, Macros.writer define unused fields forwardReader and forwardWriter. They should be deleted (to reduce jar sizes, to make scalac warnings go away and to remove dead code from the code base).

ReactiveMongo Version 0.12.1

Also, same code in the master branch here: https://github.com/ReactiveMongo/ReactiveMongo/blob/master/macros/src/main/scala-2.12/MacroImpl.scala#L11

OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

Expected Behavior

No dead code in macro-generated code. No scalac warnings on unused private variables

  1. define case class C(i: Int)
  2. enable scalac flag "-Ywarn-unused"
  3. compile

Actual Behavior

scalac shows warnings on unused private variable. The variable really has no usages in any imaginable scenario. There's just a private val defined without usages.

  1. scalac shows warnings, variable really has no usages and is unnecessary

Reproducible Test Case

see above

@vn971 vn971 changed the title macros-generated field forwardReader that never has usages macros-generated field forwardReader never has usages Apr 5, 2017
@vn971 vn971 changed the title macros-generated field forwardReader never has usages macros-generated private field forwardReader never has usages Apr 5, 2017
@vn971
Copy link
Author

vn971 commented Apr 5, 2017

I can throw in a simple PR with a fix.

@cchantep
Copy link
Member

cchantep commented Apr 6, 2017

Hi,

This lazy variable is indeed use in some case of recursive types, so it cannot be "just" removed.

@vn971
Copy link
Author

vn971 commented Apr 7, 2017

@cchantep thanks for the response! Where is it used? I only see definitions: https://github.com/ReactiveMongo/ReactiveMongo/search?utf8=%E2%9C%93&q=forwardWriter&type=

@cchantep
Copy link
Member

cchantep commented Apr 7, 2017

https://github.com/ReactiveMongo/ReactiveMongo/blob/master/macros/src/main/scala-2.12/MacroImpl.scala#L603

Please first use the MailingList (to keep this tracker clean for actionable ticket).

@cchantep cchantep closed this as completed Apr 7, 2017
@vn971
Copy link
Author

vn971 commented Apr 7, 2017

Thanks, now I see it (deeply hidden). Sorry for that. Will use the ML.

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

No branches or pull requests

2 participants