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

Scala3 derives under -Yexplicit-nulls compiler flag #2083

Closed
wants to merge 9 commits into from
Closed

Scala3 derives under -Yexplicit-nulls compiler flag #2083

wants to merge 9 commits into from

Conversation

lqhuang
Copy link

@lqhuang lqhuang commented Jan 31, 2023

Fixes #1786. Projects added -Yexplicit-nulls flag cannot compile successfully with Circe.

Previous PR #1788 seems staled, this PR takes same changes but has rebased to the latest head of current master.

The left one problem is I'm not sure whether it's correct and enough to test different compiler flags with or without -Yexplicit-nulls (see changes in build.sbt and modules/tests/shared/src/test/scala-3/io/circe/DerivesSuite.scala).

Your help and feedback are really appreciated.

Thanks!

extra info (without ScalaJS):

> sbt +test
[info] Passed: Total 1292, Failed 0, Errors 0, Passed 1292

> sbt +testsNative/test
[info] Passed: Total 1292, Failed 0, Errors 0, Passed 1292

@lqhuang
Copy link
Author

lqhuang commented Feb 1, 2023

@rossabaker Could you help to give a review here. Thx :)

@rossabaker
Copy link
Collaborator

I am not yet a Scala 3 user other than compiling several libraries for it, but this seems reasonable to me, and addresses my concern with the prior PR.

@lqhuang
Copy link
Author

lqhuang commented Feb 1, 2023

It's strange that I passed all tests with similar conditions (temurin@8, rootJVM).

My local dev environment

$ uname -a
Darwin iMac.local 22.3.0 Darwin Kernel Version 22.3.0

$ scala -version
Scala code runner version 3.2.1 -- Copyright 2002-2022, LAMP/EPFL

Tested for two JVM versions

$ java -version
openjdk version "17.0.6" 2023-01-17
OpenJDK Runtime Environment Temurin-17.0.6+10 (build 17.0.6+10)
OpenJDK 64-Bit Server VM Temurin-17.0.6+10 (build 17.0.6+10, mixed mode, sharing)

$ java -version
openjdk version "1.8.0_362"
OpenJDK Runtime Environment (Temurin)(build 1.8.0_362-b09)
OpenJDK 64-Bit Server VM (Temurin)(build 25.362-b09, mixed mode)

How could we rerun actions?

@rossabaker
Copy link
Collaborator

I can rerun it, but compiler errors are usually not flakes. In case it suddenly passes, here's the 3.2.1, temurin@8, rootJVM failure:

 [error] -- Error: /home/runner/work/circe/circe/modules/tests/shared/src/test/scala-3/io/circe/DerivesSuite.scala:134:56 
[error] 134 |  checkAll("Codec[Seq[Foo]]", CodecTests[Seq[Foo]].codec)
[error]     |                                                        ^
[error]     |Ambiguous given instances: both method eqSeq in trait MissingInstances and method catsKernelStdEqForSeq in trait SeqInstances2 match type cats.kernel.Eq[Seq[io.circe.DerivesSuite.Foo]] of parameter eqA of method codec in trait CodecTests
[warn] -- Warning: /home/runner/work/circe/circe/modules/tests/shared/src/test/scala/io/circe/JsonNumberSuite.scala:184:21 
[warn] 184 |      runCompareTest(JsonFloat, f, JsonLong, l)
[warn]     |                     ^^^^^^^^^
[warn]     |The method `apply` is inserted. The auto insertion will be deprecated, please write `io.circe.JsonFloat.apply` explicitly.
[warn] -- Warning: /home/runner/work/circe/circe/modules/tests/shared/src/test/scala/io/circe/JsonNumberSuite.scala:184:35 
[warn] 184 |      runCompareTest(JsonFloat, f, JsonLong, l)
[warn]     |                                   ^^^^^^^^
[warn]     |The method `apply` is inserted. The auto insertion will be deprecated, please write `io.circe.JsonLong.apply` explicitly.
[warn] -- Warning: /home/runner/work/circe/circe/modules/tests/shared/src/test/scala/io/circe/JsonNumberSuite.scala:190:21 
[warn] 190 |      runCompareTest(JsonFloat, f, JsonDouble, d)
[warn]     |                     ^^^^^^^^^
[warn]     |The method `apply` is inserted. The auto insertion will be deprecated, please write `io.circe.JsonFloat.apply` explicitly.
[warn] -- Warning: /home/runner/work/circe/circe/modules/tests/shared/src/test/scala/io/circe/JsonNumberSuite.scala:190:35 
[warn] 190 |      runCompareTest(JsonFloat, f, JsonDouble, d)
[warn]     |                                   ^^^^^^^^^^
[warn]     |The method `apply` is inserted. The auto insertion will be deprecated, please write `io.circe.JsonDouble.apply` explicitly.
[warn] -- Warning: /home/runner/work/circe/circe/modules/tests/shared/src/test/scala/io/circe/JsonNumberSuite.scala:196:21 
[warn] 196 |      runCompareTest(JsonFloat, f1, JsonFloat, f2)
[warn]     |                     ^^^^^^^^^
[warn]     |The method `apply` is inserted. The auto insertion will be deprecated, please write `io.circe.JsonFloat.apply` explicitly.
[warn] -- Warning: /home/runner/work/circe/circe/modules/tests/shared/src/test/scala/io/circe/JsonNumberSuite.scala:196:36 
[warn] 196 |      runCompareTest(JsonFloat, f1, JsonFloat, f2)
[warn]     |                                    ^^^^^^^^^
[warn]     |The method `apply` is inserted. The auto insertion will be deprecated, please write `io.circe.JsonFloat.apply` explicitly.
[warn] -- Warning: /home/runner/work/circe/circe/modules/tests/shared/src/test/scala/io/circe/ShowErrorSuite.scala:39:70 
[warn] 39 |  val downFields: Gen[List[CursorOp]] = Gen.listOf(Gen.identifier.map(DownField))
[warn]    |                                                                      ^^^^^^^^^
[warn]    |The method `apply` is inserted. The auto insertion will be deprecated, please write `io.circe.CursorOp.DownField.apply` explicitly.
[warn] 7 warnings found
[error] one error found
[error] (testsJVM / Test / compileIncremental) Compilation failed

@lqhuang
Copy link
Author

lqhuang commented Feb 1, 2023

Thanks! But seems more failures 😢, I will try to test them on Linux or exact Ubuntu distribution.

@rossabaker
Copy link
Collaborator

rossabaker commented Feb 1, 2023

I suspect the problem here is that the build is failing on a merge ref. That commit isn't the HEAD of your PR branch, but a merge commit that would result from merging this PR into main. While your branch is healthy, and main is healthy, the merge that would result is not. GitHub tests this merge commit to guard against these "semantic merge conflicts".

It's complaining about an amibiguous implicit instance. I didn't dig too deep, but my guess is that Cats added it since the original author started this PR, and now it's conflicting with one Circe had in MissingInstances. You probably can't remove that Circe instance due to binary compatibility, but if you remove its implicit keyword (and, ideally, deprecate it), I bet everything will work.

If you merge the latest main into your branch, I expect you'll see this error locally and be able to fix it.

@lqhuang lqhuang marked this pull request as draft February 5, 2023 08:29
@lqhuang lqhuang marked this pull request as ready for review February 5, 2023 11:31
@lqhuang
Copy link
Author

lqhuang commented Feb 5, 2023

@zarthross @rossabaker Could you review again? I have fixed problems and addressed change requests.

Thank you for your helps!

@zarthross
Copy link
Member

We need to get this branch updated and conflicts resolved, there was a big PR that refactored Derivation that just went through.

@lqhuang
Copy link
Author

lqhuang commented Feb 9, 2023

@zarthross Ok. Thank you for the reminder. I would rebase it later (probably weekend) and reorg the tests (I have passed native tests, is trying to reduce boilerplate codes for now).

@lqhuang lqhuang marked this pull request as draft February 20, 2023 01:42
@lqhuang
Copy link
Author

lqhuang commented Feb 24, 2023

@zarthross It's ready for review. And actually, after my tests, using the latest release 0.14.4, Circe can be successfully compiled by user's library with -Yexplicit-nulls flag. Hence, this PR doesn't modify any logical code, but only add a unit-test to make sure Circe could be normally compiled in third lib/app. Yeah, it just tests compiling.

Honestly, it's also fine for me to reject PR. Both -Yexplicit-nulls and staging are not very stable features in Scala 3 for now. Worry about causing extra unit-test errors in the future.

@lqhuang lqhuang marked this pull request as ready for review February 24, 2023 08:16
@lqhuang lqhuang requested a review from zarthross March 14, 2023 05:10
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.

I'm really not sure what these tests are actually testing right now? I tried adding this test and it still passes.

  test("Java boxed class would not compile without `.nn` postfix with `-Yexplicit-nulls`") {
    def code(using Quotes) = '{
      given Encoder[Instant] = Encoder.encodeString.contramap[Instant](t =>
        ISO_OFFSET_DATE_TIME
          .format(
            t.truncatedTo(MILLIS).atOffset(ZoneOffset.UTC)
          )
      )
      given Codec[Event] = Codec.AsObject.derived[Event]
    }

    staging.run(code)
  }

I realize the assertion is not correct, but i wanted to see this fail before i wrote the assertion, and when the test passed it told me the other tests passing could be a false positive.

barnardb and others added 9 commits March 16, 2023 15:43
Fixes #1786.

Since this requires a new compiler flag, I had to come up with some way
to test it. I looked into setting this flag for the tests in the tests
module, but this would have made a lot of code that is shared with
Scala 2 stop compiling, including where JDK APIs return values that are
never null but not annotated as such. I opted instead to add a
dependency on scala3-staging and use the "Runtime Multi-Stage
Programming" describe at
https://dotty.epfl.ch/docs/reference/metaprogramming/staging.html
@lqhuang
Copy link
Author

lqhuang commented Mar 16, 2023

@zarthross Thanks for your reply. It comes from a real case. Yeah, as I said:

And actually, after my tests, using the latest release 0.14.4, Circe can be successfully compiled by user's library with -Yexplicit-nulls flag.

Here is my minimal reproduction:

import java.time.Instant
import java.time.format.DateTimeFormatter.ISO_OFFSET_DATE_TIME
import java.time.temporal.ChronoUnit.MILLIS

import io.circe.{Codec, Encoder, Json}
import io.circe.syntax.*
import io.circe.parser.{decode, parse}

given Encoder[Instant] =
  Encoder.encodeString.contramap[Instant](t =>
    ISO_OFFSET_DATE_TIME.nn.format(t.truncatedTo(MILLIS).nn).nn
  )

case class InEvent(id: Int, name: String, eventTime: Instant)
    derives Codec.AsObject

@main def hello: Unit =
  val rawJson: String = """
    {
      "id": 13,
      "name": "test-event",
      "eventTime": "2023-01-05T08:04:55.697Z"
    }
    """
  val inEvent = parse(rawJson)
    .flatMap(_.as[InEvent])
    .getOrElse(InEvent(0, "error", Instant.now().nn))
  println(s"${inEvent}")
  println(msg)

def msg = "I was compiled by Scala 3 with Circe :)"

And build.sbt:

val scala3Version = "3.2.2"
val circeVersion = "0.14.3"

scalacOptions ++= Seq("-explain", "-Yexplicit-nulls")

lazy val root = project
  .in(file("."))
  .settings(
    name := "circe-nn-boxed",
    version := "0.1.0-SNAPSHOT",
    scalaVersion := scala3Version,
    libraryDependencies ++= Seq(
      "io.circe" %% "circe-core" % circeVersion,
      "io.circe" %% "circe-parser" % circeVersion,
      "org.scalameta" %% "munit" % "0.7.29" % Test
    )
  )

Above sample codes will successfully be compiled and run with circeVersion = "0.14.4" but failed with circeVersion = "0.14.3" (check following error msgs):

[error] -- [E007] Type Mismatch Error: /Users/lqhuang/Git/circe-nn-boxed/src/main/scala/Main.scala:15:18
[error]  15 |    derives Codec.AsObject
[error]     |                  ^
[error]     |                  Found:    Null
[error]     |                  Required: Left[io.circe.DecodingFailure, ?]
[error]     |---------------------------------------------------------------------------
[error]     |Inline stack trace
[error]     |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]     |This location contains code that was inlined from Derivation.scala:162
[error]      ---------------------------------------------------------------------------
[error]     |---------------------------------------------------------------------------
[error]     | Explanation (enabled by `-explain`)
[error]     |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]     |
[error]     | Tree: null
[error]     | I tried to show that
[error]     |   Null
[error]     | conforms to
[error]     |   Left[io.circe.DecodingFailure, ?]
[error]     | but the comparison trace ended with `false`:
[error]     |
[error]     |   ==> Null  <:  Left[io.circe.DecodingFailure, ?]
[error]     |   <== Null  <:  Left[io.circe.DecodingFailure, ?] = false
[error]     |
[error]     | The tests were made under the empty constraint
[error]      ---------------------------------------------------------------------------
[error] Explanation
[error] ===========
[error]
[error] Tree: null
[error] I tried to show that
[error]   Null
[error] conforms to
[error]   Left[io.circe.DecodingFailure, ?]
[error] but the comparison trace ended with `false`:
[error]
[error]   ==> Null  <:  Left[io.circe.DecodingFailure, ?]
[error]   <== Null  <:  Left[io.circe.DecodingFailure, ?] = false
[error]
[error] The tests were made under the empty constraint
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 1 s, completed Mar 16, 2023, 4:51:28 PM

You could download this to setup project minimal-reproductions.zip.

Hence, this PR doesn't modify any logical code, but only add a unit-test to make sure Circe could be normally compiled in third lib/app. Yeah, it just tests compiling.

Honestly, I have tried rebase to history to find which commits fix this problem, but I don't locate it yet. I will be appreciated if someone could teach me how to use git bisect in depth.

@lqhuang
Copy link
Author

lqhuang commented Mar 16, 2023

There is a type mismatching error if we do not use .nn to cast Java boxed object. It's an interoperability issue between Java and Scala when enabling -Yexplicit-nulls Scala 3 Docs

@lqhuang lqhuang requested a review from zarthross March 18, 2023 09:11
@zarthross
Copy link
Member

@lqhuang I completely understand what you are trying to do, you are trying to make a test to prevent the regression of support for -Yexplicit-nulls and I appreciate that, but your test does not verify that. If you take your test Java boxed class would require '.nn' postfix with '-Yexplicit-nulls' and remove the .nn annotations, the tests still passes when it clearly shouldn't based on the test name. I'm just NOT convinced that these test will prevent a regression.

I think something is wrong with your use of staging such that the error you are trying to test for, just doesn't surface.

@lqhuang
Copy link
Author

lqhuang commented Mar 21, 2023

@zarthross You're right! It's my faults. And I did some experiments and found both test cases are not actually compiled then run. Even the simplest demo not works ether.

That's probably why I didn't find which commit fix issue.

@lqhuang
Copy link
Author

lqhuang commented Mar 21, 2023

Here is my experiment. I create a Scala 3 project and using staging API to write codes directly. And I upload these codes to a repo: https://github.com/lqhuang/staging-with-case-class-and-circe or download it from attachments staging-with-case-class-and-circe-master.zip.

All 3 cases cannot normally run. There are some limits in current staging API.

Case 1

import io.circe.{Codec, Encoder, Json, Decoder}
import io.circe.syntax.*
import io.circe.parser.{decode, parse}

import scala.quoted.staging
import scala.quoted.{Quotes, Type}

@main def Case1: Unit = {
  val settings =
    staging.Compiler.Settings.make(compilerArgs = List("-Yexplicit-nulls"))
  given explicitNullsCompiler: staging.Compiler =
    staging.Compiler.make(getClass.getClassLoader)(settings)

  def code(using Quotes) = '{
    case class Foo(val i: Int, val s: String)

    given Codec[Foo] = Codec.AsObject.derived[Foo]
    given Decoder[Foo] = Decoder.derived[Foo]
    given Encoder[Foo] = Encoder.AsObject.derived[Foo]

    println(
      "Case class definitions are not allowed in inline methods or quoted code. Use a normal class instead."
    )

  }

  staging.run(code)
}

Compiler tells me that case class cannot be defined in quoted scope.

Case class definitions are not allowed in inline methods or quoted code. Use a normal class instead.

Case 2

I moved the case to outside scope and add missing Type[T], but failed again

import io.circe.{Codec, Encoder, Json, Decoder}
import io.circe.syntax.*
import io.circe.parser.{decode, parse}

import scala.quoted.staging
import scala.quoted.{Quotes, Type}

@main def Case2: Unit = {
  val settings =
    staging.Compiler.Settings.make(compilerArgs = List("-Yexplicit-nulls"))
  given explicitNullsCompiler: staging.Compiler =
    staging.Compiler.make(getClass.getClassLoader)(settings)

  case class Foo(val i: Int, val s: String) derives Codec.AsObject

  def expr(using Quotes, Type[Foo]) = '{
    given Codec[Foo] = Codec.AsObject.derived[Foo]
    given Decoder[Foo] = Decoder.derived[Foo]
    given Encoder[Foo] = Encoder.AsObject.derived[Foo]

    println(
      """access to object Foo from wrong staging level:
        |  - the definition is at level 0,
        |  - but the access is at level 1.
        """.stripMargin
    )
  }

  staging.run(expr)
}

Compiler error:

access to object Foo from wrong staging level:
  - the definition is at level 0,
  - but the access is at level 1.

Seems because the Foo is defined in the top level scope (level 0), but derives declaration is defined in the Quotes scope (level 1). This is not allowed in stage API, too.

Case 3

In case 3, just define original class and write companion object with custom codec manually (derive feature requires case class). Codes compiled successfully, but failed in runtime. I'm not very sure whether it's caused by importing circe packages.

import scala.quoted.{Quotes, staging, Type}

@main def Case3: Unit = {
  val settings =
    staging.Compiler.Settings.make(compilerArgs = List("-Yexplicit-nulls"))
  given explicitNullsCompiler: staging.Compiler =
    staging.Compiler.make(getClass.getClassLoader)(settings)

  def code(using Quotes) = '{
    import io.circe.{Codec, Encoder, Json, Decoder}
    import io.circe.syntax.*
    import io.circe.parser.{decode, parse}
    import io.circe.JsonObject

    class Foo(val i: Int, val s: String) {
      override def toString(): String = s"Foo($i, $s)"
    }

    object Foo {
      def apply(i: Int, s: String): Foo = new Foo(i, s)

      given Codec.AsObject[Foo] = {
        Codec.AsObject.from(
          Decoder.instance(c =>
            for {
              i <- c.downField("i").as[Int]
              s <- c.downField("s").as[String]
            } yield Foo(i, s)
          ),
          Encoder.AsObject.instance[Foo](x =>
            JsonObject(
              "i" -> Json.fromInt(x.i),
              "s" -> Json.fromString(x.s)
            )
          )
        )
      }
    }

    parse("{'i': 1, 's': 'string'}").flatMap(_.as[Foo]) match {
      case Left(error) => println(error)
      case Right(foo)  => println(foo)
    }
  }

  staging.run(code)
}

Error info:

[error] class dotty.tools.dotc.reporting.Diagnostic$Error at src/main/scala/Case3.scala:<1098..1129>: undefined: io.circe.parser.package.parse # -1: TermRef(TermRef(TermRef(ThisType(TypeRef(NoPrefix,module class circe)),object parser),package),parse) at quotedFrontend
[error] 	at dotty.tools.dotc.report$.error(report.scala:78)
[error] 	at dotty.tools.dotc.typer.ErrorReporting$.errorType(ErrorReporting.scala:36)
[error] 	at dotty.tools.dotc.typer.ErrorReporting$.errorType(ErrorReporting.scala:41)
[error] 	at dotty.tools.dotc.typer.TypeAssigner.assignType(TypeAssigner.scala:306)
[error] 	at dotty.tools.dotc.typer.TypeAssigner.assignType$(TypeAssigner.scala:16)
[error] 	at dotty.tools.dotc.typer.Typer.assignType(Typer.scala:121)
[error] 	at dotty.tools.dotc.ast.tpd$.Apply(tpd.scala:49)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1236)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1394)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1297)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1394)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1238)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1394)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1233)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1394)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1282)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1394)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler.dotty$tools$dotc$core$tasty$TreeUnpickler$TreeReader$$_$_$$anonfun$26(TreeUnpickler.scala:1249)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStats(TreeUnpickler.scala:1095)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readStats(TreeUnpickler.scala:1099)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1249)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1394)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1259)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1394)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1117)
[error] 	at dotty.tools.dotc.core.tasty.TreeUnpickler.unpickle(TreeUnpickler.scala:113)
[error] 	at dotty.tools.dotc.core.tasty.DottyUnpickler.computeRootTrees(DottyUnpickler.scala:62)
[error] 	at dotty.tools.dotc.ast.tpd$TreeProvider.rootTrees(tpd.scala:1280)
[error] 	at dotty.tools.dotc.ast.tpd$TreeProvider.rootTrees$(tpd.scala:1269)
[error] 	at dotty.tools.dotc.core.tasty.DottyUnpickler.rootTrees(DottyUnpickler.scala:44)
[error] 	at dotty.tools.dotc.ast.tpd$TreeProvider.tree(tpd.scala:1284)
[error] 	at dotty.tools.dotc.ast.tpd$TreeProvider.tree$(tpd.scala:1269)
[error] 	at dotty.tools.dotc.core.tasty.DottyUnpickler.tree(DottyUnpickler.scala:44)
[error] 	at dotty.tools.dotc.quoted.PickledQuotes$.unpickle(PickledQuotes.scala:257)
[error] 	at dotty.tools.dotc.quoted.PickledQuotes$.unpickleTerm(PickledQuotes.scala:83)
[error] 	at scala.quoted.runtime.impl.QuotesImpl.unpickleExprV2(QuotesImpl.scala:3044)
[error] 	at Case3$package$.code$1(Case3.scala:10)
[error] 	at Case3$package$.Case3$$anonfun$1(Case3.scala:47)
[error] 	at scala.quoted.staging.QuoteCompiler$QuotedFrontend.runOn$$anonfun$1(QuoteCompiler.scala:83)
[error] 	at scala.collection.immutable.List.flatMap(List.scala:293)
[error] 	at scala.quoted.staging.QuoteCompiler$QuotedFrontend.runOn(QuoteCompiler.scala:98)
[error] 	at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:238)
[error] 	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] 	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] 	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1321)
[error] 	at dotty.tools.dotc.Run.runPhases$1(Run.scala:249)
[error] 	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:257)
[error] 	at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:266)
[error] 	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
[error] 	at dotty.tools.dotc.Run.compileUnits(Run.scala:266)
[error] 	at dotty.tools.dotc.Run.compileUnits(Run.scala:196)
[error] 	at scala.quoted.staging.QuoteCompiler$ExprRun.compileExpr(QuoteCompiler.scala:118)
[error] 	at scala.quoted.staging.QuoteDriver.run(QuoteDriver.scala:43)
[error] 	at scala.quoted.staging.Compiler$$anon$1.run(Compiler.scala:38)
[error] 	at scala.quoted.staging.package$.run(staging.scala:19)
[error] 	at Case3$package$.Case3(Case3.scala:47)
[error] 	at Case3.main(Case3.scala:3)
[error] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[error] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[error] stack trace is suppressed; run last Compile / runMain for the full output
[error] (Compile / runMain) class dotty.tools.dotc.reporting.Diagnostic$Error at src/main/scala/Case3.scala:<1098..1129>: undefined: io.circe.parser.package.parse # -1: TermRef(TermRef(TermRef(ThisType(TypeRef(NoPrefix,module class circe)),object parser),package),parse) at quotedFrontend
[error] Total time: 1 s, completed Mar 21, 2023, 8:33:41 PM

@lqhuang
Copy link
Author

lqhuang commented Mar 21, 2023

I have no idea about how to solve it. If you have other approaches to test these behaviors, I'm glad to try it and help.

Anyway, @zarthross, really appreciate to your patience! Sorry to waste your time.

I will close the PR now or reopen it until we get something new progress in the future.

Thanks for your time!

@lqhuang lqhuang closed this Mar 21, 2023
@zarthross
Copy link
Member

No problem! I'm sorry we weren't able to get a test working. Thanks for trying! Maybe we can retry with a future Scala 3 version 😅

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.

derives Decoder and derives Codec.AsObject fail with -Yexplicit-nulls compiler option
4 participants