-
Notifications
You must be signed in to change notification settings - Fork 993
Fixing a scala compilation problem #1855
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
Fixing a scala compilation problem #1855
Conversation
Specifically, this was failing on the 7.17 branch:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, minor nit and optional simplification
case Some(None) => false | ||
case Some(_) => true | ||
case None => true | ||
case _ => false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the catch all needed here? This confused me for a second
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops good point!
@@ -61,7 +61,14 @@ class ScalaValueWriter(writeUnknownTypes: Boolean = false) extends JdkValueWrite | |||
generator.writeBeginObject() | |||
for ((k, v) <- m) { | |||
if (shouldKeep(parentField, k.toString)) { | |||
if (v != None && v!= null && v != () || hasWriteNullValues) { | |||
val nonEmptyValue = Option(v) match { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val nonEmptyValue = Option(v) match { | |
val hasValue = Option(v) match { |
Can we swap the variable name? nonEmptyValue=false
reads weird in my head
case None => true | ||
case _ => false | ||
} | ||
if (nonEmptyValue || hasWriteNullValues) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (nonEmptyValue || hasWriteNullValues) { | |
if (hasValue || hasWriteNullValues) { |
If applying above suggestion
Relates #1478 |
Fixing a scala compilation problem that happened with certain scala compilers.
Fixing a scala compilation problem that happened with certain scala compilers.
The code in ScalaValueWriter::doWriteScala was not compiling on the 7.17 branch. The problem is that the () reference to Unit was confusing the compiler. This commit makes the reference to Unit more explicit, and adds a test to make sure that Unit is being handled as expected.