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

Add support of -Yexplicit-nulls compiler option #988

Open
plokhotnyuk opened this issue Feb 5, 2023 · 4 comments
Open

Add support of -Yexplicit-nulls compiler option #988

plokhotnyuk opened this issue Feb 5, 2023 · 4 comments

Comments

@plokhotnyuk
Copy link
Owner

plokhotnyuk commented Feb 5, 2023

Macros that derive jsoniter-scala codecs encourage using non-null values, but generated codecs don't compiler validation with -Yexplicit-nulls.

Currently, workaround is using import scala.language.unsafeNulls in scopes of make macro calls, here:

given codec: JsonValueCodec[User] = {
  import scala.language.unsafeNulls

  JsonCodecMaker.make
}
@plokhotnyuk
Copy link
Owner Author

@lolgab @mohe2015 A partial support of -Yexplicit-nulls compiler option was added in v2.21.0

Now it should work for all supported types except Array and ArraySeq.

@mohe2015
Copy link

@lolgab @mohe2015 A partial support of -Yexplicit-nulls compiler option was added in v2.21.0

Now it should work for all supported types except Array and ArraySeq.

This is pretty nice! Seems like it also has issues with BigDecimal

[error] -- [E007] Type Mismatch Error: /home/moritz/Documents/reform/shared/src/main/scala/webapp/entity/SalaryChange.scala:44:71 
[error]  44 |  implicit val codec2: JsonValueCodec[BigDecimal] = JsonCodecMaker.make(CodecMakerConfig.withMapAsArray(true))
[error]     |                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]     |Found:    (java.math.MathContext.DECIMAL128 : java.math.MathContext | Null)
[error]     |Required: java.math.MathContext
[error]     |
[error]     |The following import might make progress towards fixing the problem:
[error]     |
[error]     |  import sourcecode.Text.generate
[error]     |
[error]     |---------------------------------------------------------------------------
[error]     |Inline stack trace
[error]     |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]     |This location contains code that was inlined from JsonCodecMaker.scala:824
[error]     |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]     |This location contains code that was inlined from JsonCodecMaker.scala:824
[error]      ---------------------------------------------------------------------------
[error]     |
[error]     | longer explanation available when compiling with `-explain`
[error] one error found

@plokhotnyuk
Copy link
Owner Author

@mohe2015 Please check if v2.22.1 works for you

@mohe2015
Copy link

@mohe2015 Please check if v2.22.1 works for you

Yes, looking good, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants