Malformed coverage data caused by passing super function

I'm interested if anyone here could shed some light on a very strange bug we recently encountered in our app, I don't know if this is a compiler bug or an issue with llvm-cov or xccov, but I can't really explain it.

Recently our app's coverage reports stopped working properly - coverage for various Swift packages in our workspace were still working but our main app target coverage had disappeared.

These jobs were being run by our CI process but I was able to reproduce in Xcode locally, where the build log showed that the coverage data was malformed (but not why or where).

I started the process of trying to track down the first commit in our repo where coverage started working and eventually managed to trace it to a change in revision of one of our SPM dependencies - fortunately the dependency in question was one of my own open-source libraries. There had only been a few new commits so I was able to track down the precise change in this library that broke our app target's coverage, and it was this one:

Aside from some renaming, the only real change here was the elimination of some duplication by extracting a helper function. I had a hunch which turned out to be correct - passing each super implementation into the helper function was the problem. I was able to fix this by passing in a new closure that called the super function instead:

Before I spend time trying to put together a new demo project to see if I can reproduce this, is there an obvious explanation for this?

Thanks.

2 Likes