mockito
mockito copied to clipboard
`fallbackGenerators` are actually called from real calls
The documentation for fallbackGenerators says:
The fallback values will never be returned from a real member call; these are not stub return values. They are only used internally by mockito as valid return values.
... but the actual generated code has
returnValueForMissingStub: _i10.getShim<T>(flag)
(where getShim is my fallback generator), so it does actually call fallback generator if the stub is missing and returns values to the caller. I've seen people even relying on this ;(
So, should we fix the doc or the behavior?
I believe @emmanuel-p added this in https://github.com/dart-lang/mockito/commit/5d23067c044a8b7687cfa24252ff6e498f35e4b7 (I approved). If I remember, the justification at the time was that this helped move null safety migrations along (maybe specifically in sound mode).
I don't have a strong opinion on fixing the docs or changing the behavior.
Right, G3 relies on this now, I guess we have to fix the docs.