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 negative: change in default parameter type #136

Closed
dwijnand opened this issue Nov 11, 2016 · 4 comments
Closed

False negative: change in default parameter type #136

dwijnand opened this issue Nov 11, 2016 · 4 comments
Labels
Milestone

Comments

@dwijnand
Copy link
Member

Version 1

package t

final class Foo(x: Int, y: String) {
  def copy(x: Int = x, y: String = y) = new Foo(x, y)
}

Version 2

package t

final class Foo(z: Boolean = false, x: Int, y: String) {
  def this(x: Int, y: String) = this(false, x, y)
  def copy(x: Int, y: String) = new Foo(z, x, y)
  def copy(z: Boolean = z, x: Int = x, y: String = y) = new Foo(z, x, y)
}

Client

package t

object T {
  def main(args: Array[String]): Unit = {
    val x = new Foo(1, "a")
    val y = x.copy(y = "b")
    println(y)
  }
}

Error

t: found 0 potential binary incompatibilities while checking against com.dwijnand:t_2.12:0.1.0
java.lang.NoSuchMethodError: t.Foo.copy$default$1()I
	at t.T$.main(T.scala:6)
	at t.T.main(T.scala)

Note

See sbt/contraband#48 for more context.

@szeiger
Copy link
Contributor

szeiger commented Nov 11, 2016

Looks like we shouldn't ignore the synthetic accessors for default values. AFAIR synthetic accessors are generally ignored because they cannot be called across compilation units but this is not the case here.

@jvican
Copy link

jvican commented Nov 13, 2016

I would be happy to fix this in the upcoming days.

@szeiger
Copy link
Contributor

szeiger commented Nov 22, 2016

@jvican Are you working on this or should I take a closer look? (I'd expect a fix to be pretty much along the lines of #144)

@jvican
Copy link

jvican commented Nov 22, 2016

@szeiger Go ahead, I didn't start my fix. 😉

szeiger added a commit to szeiger/migration-manager that referenced this issue Nov 23, 2016
They are called from other compilation units and their names can change
when a new overload is added to a method with default values.

Fixes lightbend#136.
@SethTisue SethTisue added the bug label Nov 29, 2016
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

4 participants