Open tschuchortdev opened 5 months ago
Aha, I didn't know this behavior but it seems that this is the semantics of inlining.
See this: https://github.com/scala/scala3/issues/12754
I agree that I should mention this in the documentation.
val r = %(name = "hello")
transparent inline def bob() = {
r + (bla = 123)
}
val r1 = bob()
r1.name
r1.bla
transparent inline def bob[R <: %](r: R = %(name = "hello")) = {
r + (bla = 123)
}
val r1 = bob()
r1.name
r1.bla
Note: this is a restricted version of generic record concatenation.
It seems to me that record4s does not work correctly neither in inline nor transparent inline functions (the difference is important since they are inlined at different times iirc). Probably this is an issue with how the type checking of transparent functions works, so not strictly a bug in this library, but perhaps you can find a better workaround or escalate the issue to the Scala compiler. In any case, I hope that my report will at least serve as documentation for other users.
Output:
PS: Let me just say that this is an amazing library that doesn't have nearly as many stars as it deserves. It is not only surprisingly usable, but also serves as a good example of whitebox macro techniques 👍