You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sealedtraitContextValuetraitEncoder[A] {
defapply(a: A):Json
}
caseclassJson()
givenEncoder[Int] = _ =>Json()
givenEncoder[Json] = a => a
extension [A:Encoder](a: A) defasJson:Json= summon[Encoder[A]](a)
objectContextValue:givenfoo[T:Encoder]:Conversion[T, ContextValue] = _.asJson
@main defdemo= println(42:ContextValue)
Output
Exception in thread "main" java.lang.StackOverflowError
at main$package$.asJson(main.scala:12)
at ContextValue$.ContextValue$$$_$foo$$anonfun$1(main.scala:15)
at ContextValue$$anon$1.apply(main.scala:15)
at ContextValue$$anon$1.apply(main.scala:15)
at ContextValue$.ContextValue$$$_$foo$$anonfun$1(main.scala:15)
at ContextValue$$anon$1.apply(main.scala:15)
at ContextValue$$anon$1.apply(main.scala:15)
at ContextValue$.ContextValue$$$_$foo$$anonfun$1(main.scala:15)
at ContextValue$$anon$1.apply(main.scala:15)
at ContextValue$$anon$1.apply(main.scala:15)
at ContextValue$.ContextValue$$$_$foo$$anonfun$1(main.scala:15)
at ContextValue$$anon$1.apply(main.scala:15)
at ContextValue$$anon$1.apply(main.scala:15)
...
Expectation
Either compilation failure or a warning. I understand that the conversions internally compiles to
Compiler version
3.6.3
Minimized code
Output
Expectation
Either compilation failure or a warning. I understand that the conversions internally compiles to
so there's an outer call to the same conversion, making it easy to detect... but it could be that it'd cause false positives. I leave it up to you.
The text was updated successfully, but these errors were encountered: