I've ran into this issue once or twice before. The problem manifests itself as this in the Force.com IDE:
The way I found the issue was by commenting out large swathes of code, and then saving the class to the server again until I narrow it down to the right section. This is quite time consuming.
The actual issue in the code was this, where I'm referencing an object that isn't in the scope of the method:
Obvious once you spot it, I would have expected it to give me an error on the line saying "Save error: Method does not exist or incorrect signature: invoices.getSObject(String)" but it doesn't. Interestingly, if I create another dummy line (below), which you would think would behave the same I do get the correct error:
SObject test = instanceoutofscope.getSObject( 'c2g__Account__r' );
Does anyone know a) the specific conditions in which this error occurs (it seems unpredictable to me), and b) of a more efficient way of detecting it?
Thanks for reading!