Here is the code.
The problems I see seem to result in referential transparency violations:
Any clues? Should I report these as bugs?
removing the return type bounds from match types seems to fix the issue: Scastie - An interactive playground for Scala. maybe the buggy behaviour is actually the compiler NOT complaining about these type bounds?
Impressive how you find these workarounds/fixes!
I submitted a bug report.