Skip to content

<local child> missing causing regression in plokhotnyuk/jsoniter-scala #24598

@WojciechMazur

Description

@WojciechMazur

plokhotnyuk/jsoniter-scala depens on existance of <local child> to detect impossible to derive typeclass instances
Seems like since switch to new stdlib publishing this approach does no longer work resulting in StackOverflowError (observed in #24597)

Compiler version

Last good release: 3.8.0-RC1-bin-20250817-8c3f1a6-NIGHTLY
First bad release: 3.8.0-RC1-bin-20250818-aaa39c5-NIGHTLY
Bisect points to aaa39c5 which is unrelated, most likely caused by switch to use Scala 3 compiled stdlib

Minimized code

//> using dep "com.github.plokhotnyuk.jsoniter-scala::jsoniter-scala-macros:2.38.5"

import com.github.plokhotnyuk.jsoniter_scala.macros.JsonCodecMaker

import scala.compiletime.testing.typeCheckErrors

@main def Test = 
    // JsonCodecMaker.make[scala.concurrent.duration.Duration]
    val err = typeCheckErrors("JsonCodecMaker.make[_root_.scala.concurrent.duration.Duration]")
    println(err)
    assert(err.exists(_.message.contains("Local child symbols are not supported")))

Output

List(Error(Exception occurred while executing macro expansion.
java.lang.StackOverflowError

,,42,Typer))
Exception in thread "main" java.lang.AssertionError: assertion failed
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:13)
        at test$package$.Test(test.scala:13)
        at Test.main(test.scala:9)

Expectation

The existing code should still work and result in

List(Error(Local child symbols are not supported, please consider change 'scala.concurrent.duration.Duration.Infinite' or implement a custom implicitly accessible codec,JsonCodecMaker.make[_root_.scala.concurrent.duration.Duration],19,Typer))

Otherwise, we'd need some other way to detect the local children

FYI @plokhotnyuk , also, would you maybe have a bit of free time to help us minimize the macro? The whole macro code is ~3k LOC and quite complex

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions