Do not extend AnyVal which triggers wrong QueryString/PathBindable #10700
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have no idea why in #7621 those
UserId
classes were made toextends AnyVal
. Back when that pull request was merged, that didn't matter. Let's again look at the code of that pull request (and that code still is alive in master):playframework/dev-mode/sbt-plugin/src/sbt-test/play-sbt-plugin/routes-compiler-injected-routes-compilation/app/models/UserId.scala
Lines 12 to 27 in b2645bd
As you can see an
implicit
pathBindable and queryStringBindable were added as well. Great, that worked.However, a couple of month later following pull requests were merged as well: #8076 and #8093
Merging those two pull request made the above pathBindable/queryStringBindable useless, because now the newly added Path/QueryStringBindable's for AnyVal kick in and the above ones just get ignored.
I ran into this when hacking on scripted tests and changed the above bindables, but nothing happend...Took me a while to figure out what's actually going on. When removing the
AnyVal
extends, above binders will be used again.I think that was the original meaning and sense of those binders, not introducing them so they are dead code...