scala/scala-abide

Override Renames Argument with Default

adriaanm opened this issue · 2 comments

I forget what the issue was -- the default getter includes the name of the argument, I guess?

default getter includes the name of the argument, I guess

no, just the position

scala> class K { def f(x: Int, y: Int = 10) = x - y }
scala> :javap K
...
  public int f$default$2();
...

not sure from the title what you meant :) one thing we should warn is exchanging names (changing a parameter name to a different name that also exists in the superclass)

scala> abstract class C { def f(x: Int, y: Int): Int }
scala> class D extends C { override def f(y: Int, x: Int) = y - x }
scala> val d = new D

scala> d.f(x = 10, y = 5)
res4: Int = -5

scala> (d: C).f(x = 10, y = 5)
res5: Int = 5

Abide is superseded by https://github.com/scalacenter/scalafix; closing all issues