[JAVA-4319] "match may not be exhaustive" with Case Class Macros Created: 30/Jul/21 Updated: 28/Oct/23 Resolved: 08/Feb/22 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Scala |
| Affects Version/s: | None |
| Fix Version/s: | 4.5.0 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Jake Schwartz | Assignee: | Ross Lawley |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | external-user | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
The following code `Macros.createCodecProviderIgnoreNone[Account]()` generates the following error
```
We have the scala compiler flags to catch missing cases, but I dont see where in the the expanded code there would be a missing case issue.
Thanks! |
| Comments |
| Comment by Ross Lawley [ 08/Feb/22 ] |
|
Added the default case class match fix from the PR #847 |
| Comment by Githook User [ 08/Feb/22 ] |
|
Author: {'name': 'Jake Schwartz', 'email': 'jakehschwartz@gmail.com', 'username': 'jakehschwartz'}Message: Include default match statement to CaseClassCodec macro Also add compile warnings to the build.
|
| Comment by Jake Schwartz [ 29/Dec/21 ] |
|
I opened a PR for this: https://github.com/mongodb/mongo-java-driver/pull/847 |
| Comment by Ross Lawley [ 28/Sep/21 ] |
|
Thanks jakeschwartz@zignallabs.com for the follow up. I'm moving this to open for a future fix. Ross |
| Comment by Jake Schwartz [ 30/Jul/21 ] |
|
Hey, sorry I cant edit the original ticket.
Dug a little deeper, looks like its caused by the `-Xlint:-strict-unsealed-patmat` compiler option, which was introduced in 2.13.4. Removing it makes the code compile I am using 2.13.6 in my code. I was able to reproduce with the Case Class Primer Quick Start code: object Person { def apply(firstName: String, lastName: String): Person = Person(new ObjectId(), firstName, lastName) }final case class Person(_id: ObjectId, firstName: String, lastName: String) class MongoTest { val codecRegistry = fromRegistries(fromProviders(classOf[Person]), DEFAULT_CODEC_REGISTRY ) val mongoClient: MongoClient = MongoClient() val database: MongoDatabase = mongoClient.getDatabase("mydb").withCodecRegistry(codecRegistry) val collection: MongoCollection[Person] = database.getCollection("test") } |
| Comment by Ross Lawley [ 30/Jul/21 ] |
|
Hi jakeschwartz@zignallabs.com, Thanks for the ticket, could you provide a full example so I can replicate the issue? Also please let me know what Scala version you are using as well. Thanks, Ross |