[JAVA-3544] Macro for case class with default values fails to compile Created: 17/Jul/17 Updated: 10/Oct/22 |
|
| Status: | Backlog |
| Project: | Java Driver |
| Component/s: | Scala |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Federico Nusymowicz | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
I'm following up on this issue. After updating the minimal github repo with Ross' suggestion, compilation still failed with the same error. So I dug into the macro, and the way default args are handled caught my eye:
Looks like default args are being stored as vals. This approach seems like it would work for simple defaults, like strings or ints. But would it work for lambda-based defaults, like ObjectId.get? |
| Comments |
| Comment by panshin [ 03/Jul/19 ] |
|
Hello! How can i help for solution of this problem? This issue blocks our migration to a new driver |
| Comment by Ross Lawley [ 18/Apr/19 ] |
|
I think https://github.com/mongodb/mongo-scala-driver/pull/60 possibly fixes this race. |
| Comment by Ross Lawley [ 22/Aug/17 ] |
|
Closing as support for default arguments is being reverted until the correct error messaging can be explained to users about how to fix. |
| Comment by Federico Nusymowicz [ 19/Jul/17 ] |
|
Great, thanks for clarifying! I'm sure lazily getting the default value will prevent lots of unexpected bugs. For now I'll rely on simple defaults. |
| Comment by Ross Lawley [ 18/Jul/17 ] |
|
Hi fedenusy13, Thanks for the ticket - this is the same issue as SCALA-324, the Entity class hasn't been compiled yet. The key thing to note is: sbt always compiles in alphabetical order and this the cause of the issue. So at the moment you can build your models first in one sbt project and then build the Registry in another relying on the models project. I'll look to update the error message and the documentation and also see if there is any way to lazily rely on getting the default value. Ross |
| Comment by Federico Nusymowicz [ 17/Jul/17 ] |
|
To be clear, the issue is that compilation is failing. The observation on lambda-based defaults is a possibly related, possibly separate issue. |