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

Support adapter type inheritance #927

Merged
merged 1 commit into from
Mar 11, 2022
Merged

Support adapter type inheritance #927

merged 1 commit into from
Mar 11, 2022

Conversation

saibotma
Copy link
Contributor

@saibotma saibotma commented Mar 11, 2022

Let P be a super type and C its subtype.

In the current implementation, TypeRegistryImpl.findAdapterForValue always picks the first match for an adapter of C. This behavior is okay. However, when two type adapters, one for P and one for C got registered (first P and then C), then TypeRegistryImpl.findAdapterForValue will always return the adapter for P and never the more specific one for C.

This PR adjusts the behavior to first return an adapter that matches the runtime type of value. When no such adapter exists, then it falls back to how the current implementation behaves.
It also adds some tests for the new implementation.

Closes #880, closes #893 and maybe #821.

I am happy to make any adjustments required to (hopefully) merge this thing fast.

Copy link
Contributor

@themisir themisir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@themisir
Copy link
Contributor

Great, Thank you for your contribution!

@themisir themisir merged commit 7b5f9fa into isar:master Mar 11, 2022
@saibotma
Copy link
Contributor Author

Any plans on when this will be released to pub.dev?

@themisir
Copy link
Contributor

Any plans on when this will be released to pub.dev?

Probably in a few days, will update you when published.

@alexobviously
Copy link

I'm also eagerly awaiting this!

@themisir
Copy link
Contributor

Can someone review #928? I want to merge it before next release but also worry if it breaks compatibility. In theory it shouldn't but real world is complicated..

@saibotma saibotma deleted the support-adapter-type-inheritance branch March 21, 2022 06:13
roubachof added a commit to roubachof/hive that referenced this pull request Apr 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using subtypes in boxes Adapter problem with Implementation of DataTime class
3 participants