Methods that re-assign parameters don't compile #51

Closed
dnadolny opened this Issue Jun 18, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@dnadolny
Contributor

dnadolny commented Jun 18, 2013

The code:

class A {
  public static void main(String[] args) {
    args = new String[] {"some", "test", "args"};
  }
}

gets converted to:

object A {
  def main(args: Array[String]) {
    args = Array("some", "test", "args")
  }
}

which doesn't compile, since method parameters are always final.

I'm not sure what the best way to fix this is. Maybe detecting re-assignment of a method parameter, changing the name in the method declaration, and creating a var with the original name (assigning the initial value to it).

@timowest

This comment has been minimized.

Show comment Hide comment
@timowest

timowest Jun 20, 2013

Owner

I'd keep this like it is, since Scalagen tries to favor idiomatic Scala code over code which compiles. Manual refactoring is the way to fix this issue on the usage side.

Owner

timowest commented Jun 20, 2013

I'd keep this like it is, since Scalagen tries to favor idiomatic Scala code over code which compiles. Manual refactoring is the way to fix this issue on the usage side.

@timowest timowest closed this Jun 20, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment