Skip to content

Conversation

i10416
Copy link
Contributor

@i10416 i10416 commented Dec 5, 2021

Hello, I added scala 3 macro support for literal module.

  • +literalJVM/test passed for scala 2.12, 2.13 and 3.1

@i10416 i10416 requested a review from zarthross as a code owner December 5, 2021 03:53
@i10416 i10416 changed the title add scala 3 support for literal add scala 3 macro support for literal Dec 5, 2021
Copy link
Member

@zarthross zarthross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, everything looks great, just a few nit picks.

Nit: Can you remove scala-3/.../LiteralInstances.scala since its not needed and its empty anyways?

build.sbt Outdated
Comment on lines 458 to 477
Compile / unmanagedSourceDirectories ++= {
def extraDirs(suffix: String) =
CrossType.Pure.sharedSrcDir(baseDirectory.value, "main").toList.map(f => file(f.getPath + suffix))

CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, y)) => extraDirs("-2") ++ (if (y >= 13) extraDirs("-2.13+") else Nil)
case Some((3, _)) => extraDirs("-3") ++ extraDirs("-2.13+")
case _ => Nil
}
},
Test / unmanagedSourceDirectories ++= {
def extraDirs(suffix: String) =
CrossType.Pure.sharedSrcDir(baseDirectory.value, "test").toList.map(f => file(f.getPath + suffix))

CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, y)) => extraDirs("-2") ++ (if (y >= 13) extraDirs("-2.13+") else Nil)
case Some((3, _)) => extraDirs("-3") ++ extraDirs("-2.13+")
case _ => Nil
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't appear to be necessary to me? I removed it and re-ran the tests for Literal and they appeared just fine. I'm pretty sure these are already being set correctly.

@@ -0,0 +1,98 @@
package io.circe.literal


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we need to run scalafmt on these changes. I see a few places missing spaces or having the space in the wrong place. Can you correct that please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

I updated scalafmt to latest for this.

@i10416
Copy link
Contributor Author

i10416 commented Dec 7, 2021

Thank you for reviewing. I will fix what you pointed out soon!

@i10416 i10416 force-pushed the support-literal-macros-for-3 branch 2 times, most recently from 88dffa5 to 3f79232 Compare December 7, 2021 02:24
update scalafmt to support macro syntax in scala 3
format literal macros
@i10416 i10416 force-pushed the support-literal-macros-for-3 branch from 3f79232 to 748e73e Compare December 7, 2021 02:26
@i10416 i10416 requested a review from zarthross December 7, 2021 02:27
@zmccoy
Copy link
Member

zmccoy commented Dec 7, 2021

@i10416 Looks like the build.sbt file isn't formatted with scalaFmt correctly.

@i10416
Copy link
Contributor Author

i10416 commented Dec 7, 2021

Oh, I forgot running scalafmtSbt

@codecov-commenter
Copy link

codecov-commenter commented Dec 7, 2021

Codecov Report

Merging #1874 (07605e9) into main (703c436) will increase coverage by 0.07%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1874      +/-   ##
==========================================
+ Coverage   86.25%   86.32%   +0.07%     
==========================================
  Files          73       73              
  Lines        2531     2531              
  Branches      143      130      -13     
==========================================
+ Hits         2183     2185       +2     
+ Misses        348      346       -2     
Impacted Files Coverage Δ
...n/scala-2/io/circe/literal/JsonLiteralMacros.scala 52.57% <ø> (ø)
.../core/shared/src/main/scala/io/circe/Decoder.scala 83.63% <0.00%> (+0.25%) ⬆️
...rc/main/scala/io/circe/numbers/BiggerDecimal.scala 88.30% <0.00%> (+0.58%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 703c436...07605e9. Read the comment docs.

@zmccoy zmccoy merged commit 33b07d3 into circe:main Dec 8, 2021
"org.scalacheck" %%% "scalacheck" % scalaCheckVersion % Test,
"org.scalameta" %%% "munit" % munitVersion % Test,
"org.scalameta" %%% "munit-scalacheck" % munitVersion % Test
)
) ++ (if (isScala3.value) Seq("org.typelevel" %% "jawn-parser" % jawnVersion)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work as-is on Scala.js.

Suggested change
) ++ (if (isScala3.value) Seq("org.typelevel" %% "jawn-parser" % jawnVersion)
) ++ (if (isScala3.value) Seq("org.typelevel" %%% "jawn-parser" % jawnVersion)

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

Successfully merging this pull request may close these issues.

5 participants