andyglow / scala-jsonschema

Scala JSON Schema
Other
123 stars 38 forks source link

Default None Option in Option #241

Closed bjornbak closed 1 year ago

bjornbak commented 2 years ago

Still trying to upgrade from 0.6.2 to 0.7.x and hit another roadblock. I am not sure if this is a bug or a feature request. Please relabel it accordingly..

Describe the bug In our model hierarchy we have optional case classes which defaults to None containing a case class which also have an optional case class which defaults None.

This worked as expected in 0.6.2 but now it results in a Unable to check isNone for the inner case class.

To Reproduce

Adding to object SchemaMacroSpec:

  case class FC(
                    name: String,
                    bar8: Option[Bar8] = None
               )

  case class CD(
                    name: String,
                    fc: Option[FC] = None
               )

and to class AsCirceSpec:

  property("Check that Schema.asCirce translates default None") {
    import SchemaMacroSpec._
    import io.circe.generic.auto._
    json.Json
      .schema[List[CD]]
      .asCirce(Draft07(id = ""))
      .toString().replaceAll("\\s", "")  shouldBe """"""
  }

Expected behavior Expected an schema generated (and the AsCirceSpec to fail because I compare the generated schema to an empty string).

Actual results But it results in a build error:

[error] /home/ubuntu/IdeaProjects/scala-jsonschema/modules/circe-json/src/test/scala/com/github/andyglow/jsonschema/AsCirceSpec.scala:121:14: exception during macro expansion: 
[error] java.lang.Exception: Unable to check isNone for com.github.andyglow.jsonschema.SchemaMacroSpec.FC.value bar8: Option[com.github.andyglow.jsonschema.SchemaMacroSpec.Bar8]. May be try non-full rebuild. Throws on evaluation of:
[error] ```
[error] com.github.andyglow.jsonschema.SchemaMacroSpec.FC.apply$default$2.isEmpty
[error] ```
[error]     at com.github.andyglow.jsonschema.UProductTypes.$anonfun$com$github$andyglow$jsonschema$UProductTypes$$resolveFields$1(UProductTypes.scala:76)
[error]     at com.github.andyglow.jsonschema.UCommons$OptionCompanionOps.whenever(UCommons.scala:174)
[error]     at com.github.andyglow.jsonschema.UProductTypes.toField$1(UProductTypes.scala:45)
[error]     at com.github.andyglow.jsonschema.UProductTypes.$anonfun$com$github$andyglow$jsonschema$UProductTypes$$resolveFields$6(UProductTypes.scala:144)
[error]     at scala.collection.immutable.List.map(List.scala:297)
[error]     at com.github.andyglow.jsonschema.UProductTypes.$anonfun$com$github$andyglow$jsonschema$UProductTypes$$resolveFields$4(UProductTypes.scala:144)
[error]     at scala.Option.map(Option.scala:230)
[error]     at com.github.andyglow.jsonschema.UProductTypes.com$github$andyglow$jsonschema$UProductTypes$$resolveFields(UProductTypes.scala:143)
[error]     at com.github.andyglow.jsonschema.UProductTypes.com$github$andyglow$jsonschema$UProductTypes$$resolveFields$(UProductTypes.scala:35)
[error]     at com.github.andyglow.jsonschema.Macroses.com$github$andyglow$jsonschema$UProductTypes$$resolveFields(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.UProductTypes$CaseClassExtractor.$anonfun$unapply$1(UProductTypes.scala:163)
[error]     at com.github.andyglow.jsonschema.UCommons.forNonValueCaseClass(UCommons.scala:117)
[error]     at com.github.andyglow.jsonschema.UCommons.forNonValueCaseClass$(UCommons.scala:109)
[error]     at com.github.andyglow.jsonschema.Macroses.forNonValueCaseClass(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.UProductTypes$CaseClassExtractor.unapply(UProductTypes.scala:158)
[error]     at com.github.andyglow.jsonschema.MacroCake.genTree$1(Macroses.scala:127)
[error]     at com.github.andyglow.jsonschema.MacroCake.$anonfun$resolve$1(Macroses.scala:136)
[error]     at scala.Option.getOrElse(Option.scala:189)
[error]     at com.github.andyglow.jsonschema.UImplicits$Implicit.getOrElse(UImplicits.scala:86)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve(Macroses.scala:136)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve$(Macroses.scala:106)
[error]     at com.github.andyglow.jsonschema.Macroses.resolve(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.UProductTypes$CaseClassExtractor.$anonfun$unapply$2(UProductTypes.scala:179)
[error]     at scala.collection.immutable.List.map(List.scala:297)
[error]     at com.github.andyglow.jsonschema.UProductTypes$CaseClassExtractor.$anonfun$unapply$1(UProductTypes.scala:175)
[error]     at com.github.andyglow.jsonschema.UCommons.forNonValueCaseClass(UCommons.scala:117)
[error]     at com.github.andyglow.jsonschema.UCommons.forNonValueCaseClass$(UCommons.scala:109)
[error]     at com.github.andyglow.jsonschema.Macroses.forNonValueCaseClass(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.UProductTypes$CaseClassExtractor.unapply(UProductTypes.scala:158)
[error]     at com.github.andyglow.jsonschema.MacroCake.genTree$1(Macroses.scala:127)
[error]     at com.github.andyglow.jsonschema.MacroCake.$anonfun$resolve$1(Macroses.scala:136)
[error]     at scala.Option.getOrElse(Option.scala:189)
[error]     at com.github.andyglow.jsonschema.UImplicits$Implicit.getOrElse(UImplicits.scala:86)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve(Macroses.scala:136)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve$(Macroses.scala:106)
[error]     at com.github.andyglow.jsonschema.Macroses.resolve(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.UArrays$ArrExtractor.$anonfun$unapply$1(UArrays.scala:12)
[error]     at com.github.andyglow.jsonschema.UCommons$SomeCompanionOps.when(UCommons.scala:169)
[error]     at com.github.andyglow.jsonschema.UArrays$ArrExtractor.unapply(UArrays.scala:9)
[error]     at com.github.andyglow.jsonschema.MacroCake.genTree$1(Macroses.scala:124)
[error]     at com.github.andyglow.jsonschema.MacroCake.$anonfun$resolve$1(Macroses.scala:136)
[error]     at scala.Option.getOrElse(Option.scala:189)
[error]     at com.github.andyglow.jsonschema.UImplicits$Implicit.getOrElse(UImplicits.scala:86)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve(Macroses.scala:136)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve$(Macroses.scala:106)
[error]     at com.github.andyglow.jsonschema.Macroses.resolve(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.MacroCake.deriveInternal(Macroses.scala:87)
[error]     at com.github.andyglow.jsonschema.MacroCake.deriveInternal$(Macroses.scala:73)
[error]     at com.github.andyglow.jsonschema.Macroses.deriveInternal(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.MacroCake.deriveSchema(Macroses.scala:56)
[error]     at com.github.andyglow.jsonschema.MacroCake.deriveSchema$(Macroses.scala:56)
[error]     at com.github.andyglow.jsonschema.Macroses.deriveSchema(Macroses.scala:141)
[error] Caused by: scala.tools.reflect.ToolBoxError: fatal compiler error
[error]     at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$.apply(ToolBoxFactory.scala:371)
[error]     at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl.compile(ToolBoxFactory.scala:437)
[error]     at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl.eval(ToolBoxFactory.scala:459)
[error]     at scala.reflect.macros.contexts.Evals.eval(Evals.scala:32)
[error]     at scala.reflect.macros.contexts.Evals.eval$(Evals.scala:26)
[error]     at scala.reflect.macros.contexts.Context.eval(Context.scala:18)
[error]     at com.github.andyglow.jsonschema.UProductTypes.$anonfun$com$github$andyglow$jsonschema$UProductTypes$$resolveFields$1(UProductTypes.scala:69)
[error]     at com.github.andyglow.jsonschema.UCommons$OptionCompanionOps.whenever(UCommons.scala:174)
[error]     at com.github.andyglow.jsonschema.UProductTypes.toField$1(UProductTypes.scala:45)
[error]     at com.github.andyglow.jsonschema.UProductTypes.$anonfun$com$github$andyglow$jsonschema$UProductTypes$$resolveFields$6(UProductTypes.scala:144)
[error]     at scala.collection.immutable.List.map(List.scala:297)
[error]     at com.github.andyglow.jsonschema.UProductTypes.$anonfun$com$github$andyglow$jsonschema$UProductTypes$$resolveFields$4(UProductTypes.scala:144)
[error]     at scala.Option.map(Option.scala:230)
[error]     at com.github.andyglow.jsonschema.UProductTypes.com$github$andyglow$jsonschema$UProductTypes$$resolveFields(UProductTypes.scala:143)
[error]     at com.github.andyglow.jsonschema.UProductTypes.com$github$andyglow$jsonschema$UProductTypes$$resolveFields$(UProductTypes.scala:35)
[error]     at com.github.andyglow.jsonschema.Macroses.com$github$andyglow$jsonschema$UProductTypes$$resolveFields(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.UProductTypes$CaseClassExtractor.$anonfun$unapply$1(UProductTypes.scala:163)
[error]     at com.github.andyglow.jsonschema.UCommons.forNonValueCaseClass(UCommons.scala:117)
[error]     at com.github.andyglow.jsonschema.UCommons.forNonValueCaseClass$(UCommons.scala:109)
[error]     at com.github.andyglow.jsonschema.Macroses.forNonValueCaseClass(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.UProductTypes$CaseClassExtractor.unapply(UProductTypes.scala:158)
[error]     at com.github.andyglow.jsonschema.MacroCake.genTree$1(Macroses.scala:127)
[error]     at com.github.andyglow.jsonschema.MacroCake.$anonfun$resolve$1(Macroses.scala:136)
[error]     at scala.Option.getOrElse(Option.scala:189)
[error]     at com.github.andyglow.jsonschema.UImplicits$Implicit.getOrElse(UImplicits.scala:86)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve(Macroses.scala:136)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve$(Macroses.scala:106)
[error]     at com.github.andyglow.jsonschema.Macroses.resolve(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.UProductTypes$CaseClassExtractor.$anonfun$unapply$2(UProductTypes.scala:179)
[error]     at scala.collection.immutable.List.map(List.scala:297)
[error]     at com.github.andyglow.jsonschema.UProductTypes$CaseClassExtractor.$anonfun$unapply$1(UProductTypes.scala:175)
[error]     at com.github.andyglow.jsonschema.UCommons.forNonValueCaseClass(UCommons.scala:117)
[error]     at com.github.andyglow.jsonschema.UCommons.forNonValueCaseClass$(UCommons.scala:109)
[error]     at com.github.andyglow.jsonschema.Macroses.forNonValueCaseClass(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.UProductTypes$CaseClassExtractor.unapply(UProductTypes.scala:158)
[error]     at com.github.andyglow.jsonschema.MacroCake.genTree$1(Macroses.scala:127)
[error]     at com.github.andyglow.jsonschema.MacroCake.$anonfun$resolve$1(Macroses.scala:136)
[error]     at scala.Option.getOrElse(Option.scala:189)
[error]     at com.github.andyglow.jsonschema.UImplicits$Implicit.getOrElse(UImplicits.scala:86)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve(Macroses.scala:136)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve$(Macroses.scala:106)
[error]     at com.github.andyglow.jsonschema.Macroses.resolve(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.UArrays$ArrExtractor.$anonfun$unapply$1(UArrays.scala:12)
[error]     at com.github.andyglow.jsonschema.UCommons$SomeCompanionOps.when(UCommons.scala:169)
[error]     at com.github.andyglow.jsonschema.UArrays$ArrExtractor.unapply(UArrays.scala:9)
[error]     at com.github.andyglow.jsonschema.MacroCake.genTree$1(Macroses.scala:124)
[error]     at com.github.andyglow.jsonschema.MacroCake.$anonfun$resolve$1(Macroses.scala:136)
[error]     at scala.Option.getOrElse(Option.scala:189)
[error]     at com.github.andyglow.jsonschema.UImplicits$Implicit.getOrElse(UImplicits.scala:86)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve(Macroses.scala:136)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve$(Macroses.scala:106)
[error]     at com.github.andyglow.jsonschema.Macroses.resolve(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.MacroCake.deriveInternal(Macroses.scala:87)
[error]     at com.github.andyglow.jsonschema.MacroCake.deriveInternal$(Macroses.scala:73)
[error]     at com.github.andyglow.jsonschema.Macroses.deriveInternal(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.MacroCake.deriveSchema(Macroses.scala:56)
[error]     at com.github.andyglow.jsonschema.MacroCake.deriveSchema$(Macroses.scala:56)
[error]     at com.github.andyglow.jsonschema.Macroses.deriveSchema(Macroses.scala:141)
[error]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error]     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error]     at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[error]     at scala.reflect.macros.runtime.JavaReflectionRuntimes$JavaReflectionResolvers.$anonfun$resolveJavaReflectionRuntime$5(JavaReflectionRuntimes.scala:45)
[error]     at scala.tools.nsc.typechecker.Macros.macroExpandWithRuntime(Macros.scala:823)
[error]     at scala.tools.nsc.typechecker.Macros.macroExpandWithRuntime$(Macros.scala:799)
[error]     at scala.tools.nsc.Global$$anon$5.macroExpandWithRuntime(Global.scala:482)
[error]     at scala.tools.nsc.typechecker.Macros$MacroExpander.$anonfun$expand$1(Macros.scala:629)
[error]     at scala.tools.nsc.Global.withInfoLevel(Global.scala:227)
[error]     at scala.tools.nsc.typechecker.Macros$MacroExpander.expand(Macros.scala:622)
[error]     at scala.tools.nsc.typechecker.Macros$MacroExpander.apply(Macros.scala:609)
[error]     at scala.tools.nsc.typechecker.Macros.standardMacroExpand(Macros.scala:784)
[error]     at scala.tools.nsc.typechecker.Macros.standardMacroExpand$(Macros.scala:782)
[error]     at scala.tools.nsc.Global$$anon$5.standardMacroExpand(Global.scala:482)
[error]     at scala.tools.nsc.typechecker.AnalyzerPlugins$$anon$10.default(AnalyzerPlugins.scala:457)
[error]     at scala.tools.nsc.typechecker.AnalyzerPlugins$$anon$10.default(AnalyzerPlugins.scala:454)
[error]     at scala.tools.nsc.typechecker.AnalyzerPlugins.invoke(AnalyzerPlugins.scala:411)
[error]     at scala.tools.nsc.typechecker.AnalyzerPlugins.pluginsMacroExpand(AnalyzerPlugins.scala:454)
[error]     at scala.tools.nsc.typechecker.AnalyzerPlugins.pluginsMacroExpand$(AnalyzerPlugins.scala:454)
[error]     at scala.tools.nsc.Global$$anon$5.pluginsMacroExpand(Global.scala:482)
[error]     at scala.tools.nsc.typechecker.Macros.macroExpand(Macros.scala:773)
[error]     at scala.tools.nsc.typechecker.Macros.macroExpand$(Macros.scala:766)
[error]     at scala.tools.nsc.Global$$anon$5.macroExpand(Global.scala:482)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.vanillaAdapt$1(Typers.scala:1164)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1227)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1200)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5795)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedSelectOrSuperCall$1(Typers.scala:5865)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5737)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5781)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typed1$39(Typers.scala:4891)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:713)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4893)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4921)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5736)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5781)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedSelectOrSuperCall$1(Typers.scala:5865)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5737)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5781)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typed1$39(Typers.scala:4891)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:713)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4893)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4921)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5736)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5781)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedSelectOrSuperCall$1(Typers.scala:5865)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5737)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5781)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typed1$39(Typers.scala:4891)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:713)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4893)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4921)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5736)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5781)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedSelectOrSuperCall$1(Typers.scala:5865)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5737)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5781)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typed1$39(Typers.scala:4891)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:713)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4893)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4921)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5736)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5781)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedBlock(Typers.scala:2498)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typed1$103(Typers.scala:5711)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedOutsidePatternMode$1(Typers.scala:500)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5746)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5781)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedArg$1(Typers.scala:3355)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedArg(Typers.scala:491)
[error]     at scala.tools.nsc.typechecker.PatternTypers$PatternTyper.typedArgWithFormal$1(PatternTypers.scala:111)
[error]     at scala.tools.nsc.typechecker.PatternTypers$PatternTyper.$anonfun$typedArgsForFormals$4(PatternTypers.scala:127)
[error]     at scala.tools.nsc.typechecker.PatternTypers$PatternTyper.typedArgsForFormals(PatternTypers.scala:127)
[error]     at scala.tools.nsc.typechecker.PatternTypers$PatternTyper.typedArgsForFormals$(PatternTypers.scala:108)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedArgsForFormals(Typers.scala:202)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.handleMonomorphicCall$1(Typers.scala:3697)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:3730)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4912)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4921)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5736)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5781)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:5845)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$10(Typers.scala:3337)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3337)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:2019)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1832)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5702)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5781)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:5845)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$10(Typers.scala:3337)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3337)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5413)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5705)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5781)
[error]     at scala.tools.nsc.typechecker.Analyzer$typerFactory$TyperPhase.apply(Analyzer.scala:114)
[error]     at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:453)
[error]     at scala.tools.nsc.typechecker.Analyzer$typerFactory$TyperPhase.run(Analyzer.scala:102)
[error]     at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1514)
[error]     at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1498)
[error]     at scala.tools.nsc.Global$Run.compileSources(Global.scala:1491)
[error]     at scala.tools.nsc.Global$Run.compileFiles(Global.scala:1602)
[error]     at xsbt.CachedCompiler0.run(CompilerBridge.scala:163)
[error]     at xsbt.CachedCompiler0.run(CompilerBridge.scala:134)
[error]     at xsbt.CompilerBridge.run(CompilerBridge.scala:39)
[error]     at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error]     at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:192)
[error]     at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error]     at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:247)
[error]     at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:182)
[error]     at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
[error]     at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error]     at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
[error]     at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:210)
[error]     at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:528)
[error]     at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:528)
[error]     at sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:177)
[error]     at sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:175)
[error]     at sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:461)
[error]     at sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error]     at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error]     at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error]     at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
[error]     at sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:416)
[error]     at sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:503)
[error]     at sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:403)
[error]     at sbt.internal.inc.Incremental$.apply(Incremental.scala:169)
[error]     at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:528)
[error]     at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:482)
[error]     at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error]     at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
[error]     at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error]     at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2366)
[error]     at sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2316)
[error]     at sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:30)
[error]     at sbt.internal.io.Retry$.apply(Retry.scala:46)
[error]     at sbt.internal.io.Retry$.apply(Retry.scala:28)
[error]     at sbt.internal.io.Retry$.apply(Retry.scala:23)
[error]     at sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:30)
[error]     at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2314)
[error]     at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error]     at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error]     at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error]     at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error]     at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error]     at sbt.Execute.work(Execute.scala:291)
[error]     at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error]     at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error]     at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error]     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]     at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error]     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error]     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error]     at java.base/java.lang.Thread.run(Thread.java:829)
[error] Caused by: scala.reflect.internal.FatalError: 
[error]   unrecoverable error
[error]      while compiling: <no file>
[error]         during phase: globalPhase=erasure, enteringPhase=posterasure
[error]      library version: version 2.12.15
[error]     compiler version: version 2.12.15
[error]   reconstructed args: 
[error] 
[error]   last tree to typer: TypeTree(class Option)
[error]        tree position: <unknown>
[error]             tree tpe: Option
[error]               symbol: (sealed abstract) class Option in package scala
[error]    symbol definition: sealed abstract class Option extends Product with Serializable (a ClassSymbol with SynchronizedClassSymbol)
[error]       symbol package: scala
[error]        symbol owners: class Option
[error]            call site: package <root> in <none>
[error] 
[error] == Source file context for tree position ==
[error] 
[error] 
[error]     at scala.reflect.internal.Reporting.abort(Reporting.scala:69)
[error]     at scala.reflect.internal.Reporting.abort$(Reporting.scala:65)
[error]     at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:28)
[error]     at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:816)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5781)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:5997)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5701)
[error]     at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:809)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5781)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:5845)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$10(Typers.scala:3337)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3337)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:2019)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1832)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5702)
[error]     at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:809)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5781)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:5845)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$10(Typers.scala:3337)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3337)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5413)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5705)
[error]     at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:809)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5781)
[error]     at scala.tools.nsc.transform.Erasure$ErasureTransformer.$anonfun$transform$2(Erasure.scala:1337)
[error]     at scala.tools.nsc.transform.Erasure$ErasureTransformer.transform(Erasure.scala:1337)
[error]     at scala.tools.nsc.transform.Erasure$ErasureTransformer.transform(Erasure.scala:863)
[error]     at scala.tools.nsc.ast.Trees$Transformer.transformUnit(Trees.scala:147)
[error]     at scala.tools.nsc.transform.Transform$Phase.apply(Transform.scala:37)
[error]     at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:453)
[error]     at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:400)
[error]     at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1514)
[error]     at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1498)
[error]     at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.wrapInPackageAndCompile(ToolBoxFactory.scala:212)
[error]     at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.compile(ToolBoxFactory.scala:267)
[error]     at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl.$anonfun$compile$13(ToolBoxFactory.scala:444)
[error]     at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$.apply(ToolBoxFactory.scala:370)
[error]     ... 212 more
[error]       .schema[List[CD]]

Versions:

Additional context Add any other context about the problem here.

andyglow commented 2 years ago

Hello, @bjornbak Can you help me to identify the corner case you are describing here? I added several test cases covering (check PR #251)

all of these scenarios get compiled/executed perfectly fine so far

what is your case?

bjornbak commented 2 years ago

Answered as a PR comment https://github.com/andyglow/scala-jsonschema/pull/251#issuecomment-1033394546

bjornbak commented 1 year ago

@andyglow Any news on this issue? Still preventing me from upgrading from 0.6.0

bjornbak commented 1 year ago

@andyglow Now that you are picking up the project any change you can take a look at this. Still stuck at 0.6.0 :(

andyglow commented 1 year ago

Sure, I will try to take a look. But in general it's a little bit tricky. Involves value evaluation, which is not what happens during compilation phase usually.

bjornbak commented 1 year ago

Do you have suggestion for a workaround other than not using default values?

andyglow commented 1 year ago

hmm. i just tried your example in scastie https://scastie.scala-lang.org/andyglow/xOKY5B81RGONu2efiNElwQ/4

and it seems to be working @bjornbak, can you please double-check?

bjornbak commented 1 year ago

Hmm I see it is working in the scastie even if I add Schema generation..

But compile still fails on our code when doing:

  val schemaJson: Json = Json
    .schema[List[AnonSenConfiguration]]
    .asCirce(Version.Draft07(id = s"http://example.com/anon-sen-config.json"))

On

final case class AnonSenConfiguration(
  entity_label: String,
  dataset: String,
  small_entity_cutoff: Option[String] = None,
  minimum_aggregated_data_size: Option[String] = None,
  alerting_algorithms: List[String] = List(),
  non_categorical_algorithm_configs: List[NonCategoricalAlgorithmConfigs] = List()
) extends Product with Serializable

I get:

[error] /tmp/workspace/scala213/dwh-preprocessor/src/main/scala/com/example/dwh/config/AnonSenConfigurationJsonSchemaGeneratorJob.scala:17:12: exception during macro expansion: 
[error] java.lang.Exception: Unable to check isNone for com.example.dwh.config.models.AnonSenConfiguration.value small_entity_cutoff: Option[String]. May be try non-full rebuild. Throws on evaluation of:
[error] ```
[error] com.example.dwh.config.models.AnonSen.apply$default$3.isEmpty
[error] ```
[error]     at com.github.andyglow.jsonschema.UProductTypes.$anonfun$com$github$andyglow$jsonschema$UProductTypes$$resolveFields$1(UProductTypes.scala:76)
[error]     at com.github.andyglow.jsonschema.UCommons$OptionCompanionOps.whenever(UCommons.scala:174)
[error]     at com.github.andyglow.jsonschema.UProductTypes.toField$1(UProductTypes.scala:45)
[error]     at com.github.andyglow.jsonschema.UProductTypes.$anonfun$com$github$andyglow$jsonschema$UProductTypes$$resolveFields$6(UProductTypes.scala:144)
[error]     at scala.collection.immutable.List.map(List.scala:250)
[error]     at com.github.andyglow.jsonschema.UProductTypes.$anonfun$com$github$andyglow$jsonschema$UProductTypes$$resolveFields$4(UProductTypes.scala:144)
[error]     at scala.Option.map(Option.scala:242)
[error]     at com.github.andyglow.jsonschema.UProductTypes.com$github$andyglow$jsonschema$UProductTypes$$resolveFields(UProductTypes.scala:143)
[error]     at com.github.andyglow.jsonschema.UProductTypes.com$github$andyglow$jsonschema$UProductTypes$$resolveFields$(UProductTypes.scala:35)
[error]     at com.github.andyglow.jsonschema.Macroses.com$github$andyglow$jsonschema$UProductTypes$$resolveFields(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.UProductTypes$CaseClassExtractor.$anonfun$unapply$1(UProductTypes.scala:163)
[error]     at com.github.andyglow.jsonschema.UCommons.forNonValueCaseClass(UCommons.scala:117)
[error]     at com.github.andyglow.jsonschema.UCommons.forNonValueCaseClass$(UCommons.scala:109)
[error]     at com.github.andyglow.jsonschema.Macroses.forNonValueCaseClass(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.UProductTypes$CaseClassExtractor.unapply(UProductTypes.scala:158)
[error]     at com.github.andyglow.jsonschema.MacroCake.genTree$1(Macroses.scala:127)
[error]     at com.github.andyglow.jsonschema.MacroCake.$anonfun$resolve$1(Macroses.scala:136)
[error]     at scala.Option.getOrElse(Option.scala:201)
[error]     at com.github.andyglow.jsonschema.UImplicits$Implicit.getOrElse(UImplicits.scala:86)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve(Macroses.scala:136)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve$(Macroses.scala:106)
[error]     at com.github.andyglow.jsonschema.Macroses.resolve(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.UArrays$ArrExtractor.$anonfun$unapply$1(UArrays.scala:12)
[error]     at com.github.andyglow.jsonschema.UCommons$SomeCompanionOps.when(UCommons.scala:169)
[error]     at com.github.andyglow.jsonschema.UArrays$ArrExtractor.unapply(UArrays.scala:9)
[error]     at com.github.andyglow.jsonschema.MacroCake.genTree$1(Macroses.scala:124)
[error]     at com.github.andyglow.jsonschema.MacroCake.$anonfun$resolve$1(Macroses.scala:136)
[error]     at scala.Option.getOrElse(Option.scala:201)
[error]     at com.github.andyglow.jsonschema.UImplicits$Implicit.getOrElse(UImplicits.scala:86)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve(Macroses.scala:136)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve$(Macroses.scala:106)
[error]     at com.github.andyglow.jsonschema.Macroses.resolve(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.MacroCake.deriveInternal(Macroses.scala:87)
[error]     at com.github.andyglow.jsonschema.MacroCake.deriveInternal$(Macroses.scala:73)
[error]     at com.github.andyglow.jsonschema.Macroses.deriveInternal(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.MacroCake.deriveSchema(Macroses.scala:56)
[error]     at com.github.andyglow.jsonschema.MacroCake.deriveSchema$(Macroses.scala:56)
[error]     at com.github.andyglow.jsonschema.Macroses.deriveSchema(Macroses.scala:141)
[error] Caused by: java.lang.AssertionError: assertion failed: pkgClass = package <root>, sym = package com, existing = package com (depth=0)
[error]     at scala.reflect.internal.SymbolTable.throwAssertionError(SymbolTable.scala:171)
[error]     at scala.reflect.runtime.SymbolLoaders$PackageScope.enter(SymbolLoaders.scala:120)
[error]     at scala.reflect.internal.Importers$StandardImporter.$anonfun$importSymbol$6(Importers.scala:210)
[error]     at scala.reflect.internal.Symbols$Symbol.orElse(Symbols.scala:2647)
[error]     at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:206)
[error]     at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:223)
[error]     at scala.reflect.internal.Importers$StandardImporter.recreatedTreeCompleter(Importers.scala:312)
[error]     at scala.reflect.internal.Importers$StandardImporter.$anonfun$importTree$1(Importers.scala:432)
[error]     at scala.reflect.internal.Importers$StandardImporter.tryFixup(Importers.scala:61)
[error]     at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:433)
[error]     at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:397)
[error]     at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:430)
[error]     at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:397)
[error]     at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:430)
[error]     at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:397)
[error]     at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:430)
[error]     at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:397)
[error]     at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:430)
[error]     at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:397)
[error]     at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:430)
[error]     at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:397)
[error]     at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:430)
[error]     at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:397)
[error]     at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:430)
[error]     at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:41)
[error]     at scala.reflect.macros.contexts.Evals.eval(Evals.scala:37)
[error]     at scala.reflect.macros.contexts.Evals.eval$(Evals.scala:26)
[error]     at scala.reflect.macros.contexts.Context.eval(Context.scala:18)
[error]     at com.github.andyglow.jsonschema.UProductTypes.$anonfun$com$github$andyglow$jsonschema$UProductTypes$$resolveFields$1(UProductTypes.scala:69)
[error]     at com.github.andyglow.jsonschema.UCommons$OptionCompanionOps.whenever(UCommons.scala:174)
[error]     at com.github.andyglow.jsonschema.UProductTypes.toField$1(UProductTypes.scala:45)
[error]     at com.github.andyglow.jsonschema.UProductTypes.$anonfun$com$github$andyglow$jsonschema$UProductTypes$$resolveFields$6(UProductTypes.scala:144)
[error]     at scala.collection.immutable.List.map(List.scala:250)
[error]     at com.github.andyglow.jsonschema.UProductTypes.$anonfun$com$github$andyglow$jsonschema$UProductTypes$$resolveFields$4(UProductTypes.scala:144)
[error]     at scala.Option.map(Option.scala:242)
[error]     at com.github.andyglow.jsonschema.UProductTypes.com$github$andyglow$jsonschema$UProductTypes$$resolveFields(UProductTypes.scala:143)
[error]     at com.github.andyglow.jsonschema.UProductTypes.com$github$andyglow$jsonschema$UProductTypes$$resolveFields$(UProductTypes.scala:35)
[error]     at com.github.andyglow.jsonschema.Macroses.com$github$andyglow$jsonschema$UProductTypes$$resolveFields(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.UProductTypes$CaseClassExtractor.$anonfun$unapply$1(UProductTypes.scala:163)
[error]     at com.github.andyglow.jsonschema.UCommons.forNonValueCaseClass(UCommons.scala:117)
[error]     at com.github.andyglow.jsonschema.UCommons.forNonValueCaseClass$(UCommons.scala:109)
[error]     at com.github.andyglow.jsonschema.Macroses.forNonValueCaseClass(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.UProductTypes$CaseClassExtractor.unapply(UProductTypes.scala:158)
[error]     at com.github.andyglow.jsonschema.MacroCake.genTree$1(Macroses.scala:127)
[error]     at com.github.andyglow.jsonschema.MacroCake.$anonfun$resolve$1(Macroses.scala:136)
[error]     at scala.Option.getOrElse(Option.scala:201)
[error]     at com.github.andyglow.jsonschema.UImplicits$Implicit.getOrElse(UImplicits.scala:86)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve(Macroses.scala:136)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve$(Macroses.scala:106)
[error]     at com.github.andyglow.jsonschema.Macroses.resolve(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.UArrays$ArrExtractor.$anonfun$unapply$1(UArrays.scala:12)
[error]     at com.github.andyglow.jsonschema.UCommons$SomeCompanionOps.when(UCommons.scala:169)
[error]     at com.github.andyglow.jsonschema.UArrays$ArrExtractor.unapply(UArrays.scala:9)
[error]     at com.github.andyglow.jsonschema.MacroCake.genTree$1(Macroses.scala:124)
[error]     at com.github.andyglow.jsonschema.MacroCake.$anonfun$resolve$1(Macroses.scala:136)
[error]     at scala.Option.getOrElse(Option.scala:201)
[error]     at com.github.andyglow.jsonschema.UImplicits$Implicit.getOrElse(UImplicits.scala:86)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve(Macroses.scala:136)
[error]     at com.github.andyglow.jsonschema.MacroCake.resolve$(Macroses.scala:106)
[error]     at com.github.andyglow.jsonschema.Macroses.resolve(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.MacroCake.deriveInternal(Macroses.scala:87)
[error]     at com.github.andyglow.jsonschema.MacroCake.deriveInternal$(Macroses.scala:73)
[error]     at com.github.andyglow.jsonschema.Macroses.deriveInternal(Macroses.scala:141)
[error]     at com.github.andyglow.jsonschema.MacroCake.deriveSchema(Macroses.scala:56)
[error]     at com.github.andyglow.jsonschema.MacroCake.deriveSchema$(Macroses.scala:56)
[error]     at com.github.andyglow.jsonschema.Macroses.deriveSchema(Macroses.scala:141)
[error]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error]     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error]     at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[error]     at scala.reflect.macros.runtime.JavaReflectionRuntimes$JavaReflectionResolvers.$anonfun$resolveJavaReflectionRuntime$5(JavaReflectionRuntimes.scala:45)
[error]     at scala.tools.nsc.typechecker.Macros.macroExpandWithRuntime(Macros.scala:796)
[error]     at scala.tools.nsc.typechecker.Macros.macroExpandWithRuntime$(Macros.scala:772)
[error]     at scala.tools.nsc.Global$$anon$6.macroExpandWithRuntime(Global.scala:511)
[error]     at scala.tools.nsc.typechecker.Macros$MacroExpander.$anonfun$expand$2(Macros.scala:601)
[error]     at scala.tools.nsc.Global.withInfoLevel(Global.scala:254)
[error]     at scala.tools.nsc.typechecker.Macros$MacroExpander.expand(Macros.scala:594)
[error]     at scala.tools.nsc.typechecker.Macros$MacroExpander.apply(Macros.scala:556)
[error]     at scala.tools.nsc.typechecker.Macros.standardMacroExpand(Macros.scala:757)
[error]     at scala.tools.nsc.typechecker.Macros.standardMacroExpand$(Macros.scala:755)
[error]     at scala.tools.nsc.Global$$anon$6.standardMacroExpand(Global.scala:511)
[error]     at scala.tools.nsc.typechecker.AnalyzerPlugins$$anon$11.default(AnalyzerPlugins.scala:474)
[error]     at scala.tools.nsc.typechecker.AnalyzerPlugins$$anon$11.default(AnalyzerPlugins.scala:471)
[error]     at scala.tools.nsc.typechecker.AnalyzerPlugins.invoke(AnalyzerPlugins.scala:428)
[error]     at scala.tools.nsc.typechecker.AnalyzerPlugins.pluginsMacroExpand(AnalyzerPlugins.scala:471)
[error]     at scala.tools.nsc.typechecker.AnalyzerPlugins.pluginsMacroExpand$(AnalyzerPlugins.scala:471)
[error]     at scala.tools.nsc.Global$$anon$6.pluginsMacroExpand(Global.scala:511)
[error]     at scala.tools.nsc.typechecker.Macros.macroExpand(Macros.scala:746)
[error]     at scala.tools.nsc.typechecker.Macros.macroExpand$(Macros.scala:739)
[error]     at scala.tools.nsc.Global$$anon$6.macroExpand(Global.scala:511)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.vanillaAdapt$1(Typers.scala:1227)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1298)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1271)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:6132)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedSelectOrSuperCall$1(Typers.scala:6215)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:6062)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:6117)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typed1$41(Typers.scala:5130)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:697)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:5132)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:5164)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:6061)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:6117)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedValDefImpl(Typers.scala:6381)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedValDef(Typers.scala:2124)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:6022)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:6117)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:6195)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$8(Typers.scala:3455)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3455)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:2078)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1954)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:6025)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:6117)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:6195)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$8(Typers.scala:3455)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3455)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5707)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:6027)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:6117)
[error]     at scala.tools.nsc.typechecker.Analyzer$typerFactory$TyperPhase.apply(Analyzer.scala:124)
[error]     at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:480)
[error]     at scala.tools.nsc.typechecker.Analyzer$typerFactory$TyperPhase.run(Analyzer.scala:111)
[error]     at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1545)
[error]     at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1529)
[error]     at scala.tools.nsc.Global$Run.compileSources(Global.scala:1521)
[error]     at scala.tools.nsc.Global$Run.compileFiles(Global.scala:1634)
[error]     at xsbt.CachedCompiler0.run(CompilerBridge.scala:163)
[error]     at xsbt.CachedCompiler0.run(CompilerBridge.scala:134)
[error]     at xsbt.CompilerBridge.run(CompilerBridge.scala:39)
[error]     at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error]     at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:193)
[error]     at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error]     at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:248)
[error]     at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:183)
[error]     at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
[error]     at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error]     at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
[error]     at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:211)
[error]     at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534)
[error]     at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534)
[error]     at sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:179)
[error]     at sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:177)
[error]     at sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:463)
[error]     at sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error]     at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error]     at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error]     at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
[error]     at sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:418)
[error]     at sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:505)
[error]     at sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:405)
[error]     at sbt.internal.inc.Incremental$.apply(Incremental.scala:171)
[error]     at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534)
[error]     at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488)
[error]     at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error]     at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425)
[error]     at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error]     at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2369)
[error]     at sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2319)
[error]     at sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:31)
[error]     at sbt.internal.io.Retry$.apply(Retry.scala:47)
[error]     at sbt.internal.io.Retry$.apply(Retry.scala:29)
[error]     at sbt.internal.io.Retry$.apply(Retry.scala:24)
[error]     at sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
[error]     at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2317)
[error]     at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error]     at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error]     at sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error]     at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error]     at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error]     at sbt.Execute.work(Execute.scala:292)
[error]     at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error]     at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error]     at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error]     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]     at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error]     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error]     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error]     at java.base/java.lang.Thread.run(Thread.java:829)
[error]     .schema[List[AnonSenConfiguration]]
bjornbak commented 1 year ago

I couldn't reliably reproduce it in the scastie and I solved it in our codebase too :) But I can't tell you how as it was a lucky break of:

:question: :grey_question: :thinking: but it is working :)