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

Syntactic sugar rejected for calling setter function that has a formal implicit parameter having a parameterized type #8969

Closed
scabug opened this issue Nov 9, 2014 · 2 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Nov 9, 2014

Welcome to Scala version 2.11.1-20141007-151233-f67aa50599 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_65).
Type in expressions to have them evaluated.
Type :help for more information.

scala> object Test {
     |   def a[R](implicit s: List[R]):Int = 0
     |   def a_=[R](v: Int)(implicit s: List[R]) = ()
     | }
defined object Test

scala> import Test._
import Test._

scala> implicit val implicitVal:List[Int]=null
implicitVal: List[Int] = null

scala> a_=(1)

scala> a = 1
<console>:50: error: reassignment to val
       a = 1
         ^

So the syntactic sugar version "a = 1" is rejected while the (I presume) equivalent raw version "a_=(1)" is accepted.

This does not seem to happen when the implicit parameter is of a type that is not parameterized:

scala> object Test1 {
     |   def b(implicit s: String) = 0
     |   def b_=(v: Int)(implicit s: String) = ()
     | }
defined object Test1

scala> import Test1._
import Test1._

scala> implicit val implicitString = ""
implicitString: String = ""

scala> b_=(1)

scala> b = 1
b: Int = 0

Issue #4237 has a title that also covers this problem: "Syntactic sugar for calling mutator doesn't always work"; however it has already been closed.

@scabug
Copy link
Author

scabug commented Nov 9, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8969?orig=1
Reporter: André van Delft
Affected Versions: 2.12.1
See #4237

@scabug
Copy link
Author

scabug commented Mar 9, 2017

@som-snytt said:
scala/scala#5769

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

No branches or pull requests

2 participants