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

applyDynamic is not used for a call to apply that is not explicit #6353

Closed
scabug opened this issue Sep 10, 2012 · 8 comments
Closed

applyDynamic is not used for a call to apply that is not explicit #6353

scabug opened this issue Sep 10, 2012 · 8 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Sep 10, 2012

import language.dynamics

object I {
   val x = new X(3)

   // Doesn't compile.  It should be a call to applyDynamic("apply")(9)
   val y = x(9)

   class X(i: Int) extends Dynamic {
      def applyDynamic(name: String)(in: Int): Int = i + in
   }
}
I.scala:7: error: I.X does not take parameters
   val y = x(9)
            ^

The above is unexpected because applyDynamic does get called for update. The following compiles fine:

import language.dynamics

object I {
   val x = new X(3)
   x(9) = 12

   class X(i: Int) extends Dynamic {
      def applyDynamic(name: String)(left: Int, right: Int): Int = 
         i + left + right
   }
}
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Sep 10, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6353?orig=1
Reporter: @harrah
Affected Versions: 2.10.0-M7, 2.10.0
Other Milestones: 2.10.0

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Sep 13, 2012

@jsuereth said:
This SIP proposal mentions nothing about "apply". I think perhaps we just need to make a decision here, but this may be "not a bug".

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Sep 13, 2012

@harrah said:
Section 6.6 of the spec describes how x(9) is translated to x.apply(9), so I don't think the SIP needs to mention anything specifically about "apply" unless there will be an exception that dynamic doesn't kick in for "apply". An updated section 6.6 for this SIP or an explicit note in the SIP would of course make this clearer, but because of the handling of "update", I think it is reasonable to infer the SIP means to handle "apply" like everything else.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Sep 14, 2012

@gkossakowski said:
I believe Mark is right here.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Sep 14, 2012

@jsuereth said:
Yeah, Mark is right. We either explicitly disallow or fix. I already bumped to critical, do we need to bump to blocker?

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Sep 14, 2012

@gkossakowski said:
I think we just need to find somebody who can fix it. Unfortunately, type checker is not area of my expertise but let me look around for folks more knowledgeable than me.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Sep 14, 2012

@gkossakowski said:
Nada has a lot of experience with dynamic so she is probably the best fit. She said she will have a look at this ticket on Tuesday.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Sep 17, 2012

@gkossakowski said:
Fixed by Nada here: scala/scala#1321

@scabug scabug closed this Sep 17, 2012
@scabug scabug added this to the 2.10.0-M7 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.