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

Scala 2.13: Natural arg-order calling storeJsonBody #25333

Merged

Conversation

rtyley
Copy link
Member

@rtyley rtyley commented Aug 2, 2022

Scala 2.13 doesn't like the way the code was previously calling commercial.controllers.Analytics.storeJsonBody() - effectively, the first 3 arguments, then the last 2 implicit arguments, and then the middle non-implicit analytics: String argument. Although this worked in Scala 2.12, in Scala 2.13, this error was raised:

/Users/ioanna_kokkini/Projects/frontend/commercial/app/controllers/PrebidAnalyticsController.scala:16:43: Cannot find any HTTP Request here
[error]       val stream = Analytics.storeJsonBody(Switches.prebidAnalytics, prebidAnalyticsStream, log) _
[error]

"Cannot find any HTTP Request here" comes from the implicit play.api.mvc.Request not being found by the Scala 2.13 compiler, which I guess was confused by the method parameter order!

The fix is to just inline the code a bit, and supply the middle analytics: String argument in it's natural 2nd position,
and allow the compiler to then find the last pair of implicit arguments.

Scala 2.13 doesn't like the way the code was previously calling
`commercial.controllers.Analytics.storeJsonBody()` - effectively,
the first 3 arguments, then the last 2 implicit arguments, and then
the _middle_ non-implicit `analytics: String` argument. Although this
worked in Scala 2.12, in Scala 2.13, this error was raised:

```
/Users/ioanna_kokkini/Projects/frontend/commercial/app/controllers/PrebidAnalyticsController.scala:16:43: Cannot find any HTTP Request here
[error]       val stream = Analytics.storeJsonBody(Switches.prebidAnalytics, prebidAnalyticsStream, log) _
[error]
```

"Cannot find any HTTP Request here" comes from the implicit
`play.api.mvc.Request` not being found by the Scala 2.13 compiler,
which I guess was a little confused by the method parameter order.

https://github.com/playframework/playframework/blob/59c907fae50481b5c2b8c4313f3aedd39d293d62/core/play/src/main/scala/play/api/mvc/Request.scala#L27-L28

The fix is to just inline the code a bit, and supply the
_middle_ `analytics: String` argument in it's natural 2nd position,
and allow the compiler to then find the last pair of implicit
arguments.

Co-authored-by: Ioanna Kokkini <ioanna.kokkini@guardian.co.uk>
@rtyley rtyley requested a review from a team as a code owner August 2, 2022 15:44
@rtyley rtyley mentioned this pull request Aug 2, 2022
2 tasks
Copy link
Member

@kelvin-chappell kelvin-chappell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@rtyley rtyley merged commit fed696e into main Aug 3, 2022
@rtyley rtyley deleted the call-storeJsonBody-with-natural-arg-order-for-scala-2.13 branch August 3, 2022 09:27
@prout-bot
Copy link
Collaborator

Overdue on PROD (merged by @rtyley 30 minutes and 7 seconds ago) What's gone wrong?

@prout-bot
Copy link
Collaborator

Seen on PROD (merged by @rtyley 1 hour, 8 minutes and 12 seconds ago)

@rtyley rtyley added the Scala 2.13 See https://github.com/guardian/maintaining-scala-projects/issues/2 label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scala 2.13 See https://github.com/guardian/maintaining-scala-projects/issues/2 Seen-on-PROD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants