You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
=== What steps will reproduce the problem (please be specific and use wikiformatting)? ===
(new { deffield=0; deffield_=(i: Int) = () }).field =5// compiles as expected
(new { deffield(impliciti: Int) =0; deffield_=(i: Int) = () }).field =5// compiles even with implicit params on getter
(new { deffield=0; deffield_=[T](i: Int) = () }).field =5// compiles with type param on setter
(new { deffield[T] =0; deffield_=(i: Int) = () }).field =5// DOESN'T COMPILE
=== What is the expected behavior? ===
According to the standard, "If x is a parameterless function defined in some template, and the same template contains a setter function x_= as member, then the assignment x = e is interpreted as the invocation x_=(e) of that setter function. Analogously, an assignment f .x = e to a parameterless function x is interpreted as the invocation f.x_=(e)".
I would expect the fourth case to compile as the getter has no parameters.
If I'm allowed to add type parameters to the setter and it still works, I'd expect to be able to add type parameters to the getter as well.
=== What do you see instead? ===
The fourth case doesn't compile and fails with "error: reassignment to val".
=== Additional information ===
Bug is possibly in method typedAssign in Typers.scala
=== What versions of the following are you using? ===
Scala: 2.8.1
Java: 1.6.0_22
Operating system: Mac OS X 10.6.6
The text was updated successfully, but these errors were encountered:
Commit Message Bot (anonymous) said:
(extempore in r25048) A getter with type params is still a getter. Closes #4237.
There were two distinct bugs in here, which if I ran the world
would be a wakeup call that robust software cannot emerge from
thousands of lines of low-level AST matching. In case you are
frozen in suspense: I do not run the world. Review by moors.
=== What steps will reproduce the problem (please be specific and use wikiformatting)? ===
=== What is the expected behavior? ===
According to the standard, "If x is a parameterless function defined in some template, and the same template contains a setter function x_= as member, then the assignment x = e is interpreted as the invocation x_=(e) of that setter function. Analogously, an assignment f .x = e to a parameterless function x is interpreted as the invocation f.x_=(e)".
I would expect the fourth case to compile as the getter has no parameters.
If I'm allowed to add type parameters to the setter and it still works, I'd expect to be able to add type parameters to the getter as well.
=== What do you see instead? ===
The fourth case doesn't compile and fails with "error: reassignment to val".
=== Additional information ===
Bug is possibly in method typedAssign in Typers.scala
=== What versions of the following are you using? ===
The text was updated successfully, but these errors were encountered: