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

Compilation with the plugin produces warning after updating to 2.x #476

Open
kubukoz opened this issue Oct 25, 2022 · 2 comments
Open

Compilation with the plugin produces warning after updating to 2.x #476

kubukoz opened this issue Oct 25, 2022 · 2 comments
Labels

Comments

@kubukoz
Copy link

kubukoz commented Oct 25, 2022

It might be a compiler plugin issue more than an sbt plugin issue, but it seems like I can't get one without the other so I'm reporting here:

For users of https://github.com/polyvariant/better-tostring, updating scoverage to 2.x causes a warning to be emitted (with fatal warnings, that becomes an error).

For example, this Scala:

case class A(s: String, s2: String)

gets rewritten by better-tostring to something like the following:

case class A(s: String, s2: String {
  override def toString: String = "A(" + "s = " + s + ", " + "s2 = " + s2 + ")"
}

and the scoverage plugin complains:

[error] Could not instrument [Apply/method +].

Notably, this worked in sbt-scoverage 1.9.3 but doesn't work in 2.0.5. I'm using Scala 2.13.8, as it happens to be a stable version where both versions of scoverage work (as well as the latest better-tostring).

I might be able to work around this by ignoring the issue on Apply/method +, but I'm not sure what the impact would be, so wanted to report it anyway.

Reproduction

  1. clone https://github.com/kubukoz/demos/tree/scoverage-change-b2s

  2. in the project:

sbt
clean;coverage;compile
  1. the above will fail. Switch versions of sbt-scoverage in plugins.sbt, and it starts working again.
@ckipp01
Copy link
Member

ckipp01 commented Oct 26, 2022

Thanks for reporting @kubukoz. Oddly enough I still see the warning when using the older sbt-scoverage:

[info] Beginning coverage instrumentation
[info] [warn] Could not instrument [Apply/method +]. No pos.
[info] Instrumentation completed [0 statements]

But it doesn't fail anything, whereas as you pointed out, the new one does:

[info] Beginning coverage instrumentation
[error] Could not instrument [Apply/method +].
[info] Instrumentation completed [0 statements]

I'm actually not 100% sure why this is different here. It'll need some more investigation. I won't move this over yet to the actual compiler plugin because I'd want to ensure I understand where the actual issue stems from first.

@ckipp01 ckipp01 added the bug label Oct 26, 2022
@kubukoz
Copy link
Author

kubukoz commented Oct 26, 2022

Yeah, should've been more specific, that's the behavior I was seeing as well.

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

No branches or pull requests

2 participants