Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tighten generics #241

Open
davidmorgan opened this issue Jun 9, 2021 · 2 comments
Open

Tighten generics #241

davidmorgan opened this issue Jun 9, 2021 · 2 comments
Assignees

Comments

@davidmorgan
Copy link
Contributor

e.g. making replace taking an Iterable and having a separate method replaceFrom.

It's a breaking API change, so we likely want to do all related improvements in one shot.

@dowski
Copy link

dowski commented Mar 29, 2022

Does this apply to all replace methods, e.g. this one on MapBuilder?

void replace(Object map) {

I got hit a runtime crash the other day b/c Object is so permissive.

@davidmorgan
Copy link
Contributor Author

Map.replace is a slightly different case; there is no common superinterface between BuiltMap and Map, so the only way to accept either is to accept Object.

Possible ways forward: 1) get the SDK to add some superinterface e.g. HasEntries<K, V>; 2) add a lint that checks you pass only Map or BuiltMap; 3) change the API to have separate methods for accepting Map and BuiltMap.

I'll look at this when I get to looking at the other breaking changes, so this is the right issue for it.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants