Skip to content

Support adapter type inheritance#927

Merged
themisir merged 1 commit into
isar:masterfrom
saibotma:support-adapter-type-inheritance
Mar 11, 2022
Merged

Support adapter type inheritance#927
themisir merged 1 commit into
isar:masterfrom
saibotma:support-adapter-type-inheritance

Conversation

@saibotma

@saibotma saibotma commented Mar 11, 2022

Copy link
Copy Markdown
Contributor

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.

@themisir themisir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@themisir

Copy link
Copy Markdown
Contributor

Great, Thank you for your contribution!

@themisir themisir merged commit 7b5f9fa into isar:master Mar 11, 2022
@saibotma

Copy link
Copy Markdown
Contributor Author

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

@themisir

Copy link
Copy Markdown
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
Copy Markdown

I'm also eagerly awaiting this!

@themisir

Copy link
Copy Markdown
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