Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid assertions on model type in .error()
It's too complicated to figure out if models are likely compatible or incompatible. The current logic is broken if we have three classes, Parent, Child1 and Child2 where both the Child classes extend parent. We want Child1 and Child2 to be compatible, but they won't be because Child2 is not assignable to Child1. Anything we do that's more sophisticated is likely to be heuristic anyway. Ideally we'd just unapply the automatically applied options from the original model and apply the correct automatic options (if any) for the new model. Keeping track of which options can be undone and which options should be re-applied is quite difficult, in part because they automatic options could also be deliberately applied. Rather than do anything intelligent, we'll rely on callers to use the API appropriately and update the javadoc to warn more. In general I expect the common case to be matching models and there's a reasonable fallback if people have trouble. Unfortunately I expect this won't be perfect, there will be some amount of debugging caused by someone expecting or not expecting a default option :/. I think the tradeoff of not having to create a new request builder and duplicate options for that request builder is probably worth the cost. PiperOrigin-RevId: 345085610
- Loading branch information