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

Make type comparisons clearer #80

Closed
paddycarver opened this issue Apr 21, 2021 · 1 comment · Fixed by #94
Closed

Make type comparisons clearer #80

paddycarver opened this issue Apr 21, 2021 · 1 comment · Fixed by #94
Assignees
Labels
breaking-change This will impact or improve our compatibility posture

Comments

@paddycarver
Copy link
Contributor

We currently have a very overloaded Is method on types that's used for shallow and deep comparisons. With #79 raising the need for deep comparisons that allow concrete types to be substituted for DynamicPseudoTypes, it has become obvious we need a clearer interface for this.

I'm proposing:

  • Type.Is(Type) is a shallow check, that root types are the same type
  • Type.Equals(Type) is a deep check, that root types and all elements and attributes are the same type
  • Type.ConformsTo(Type) is a deep check, that root types and all elements and attributes conform (are equivalent, or a concrete type is being substituted for DynamicPseudoType)

This would lead to less confusion and fewer gotchas around Type.Is(Type), I believe, and more clarity about what code is actually doing.

@paddycarver paddycarver added the breaking-change This will impact or improve our compatibility posture label Apr 21, 2021
@bflad bflad self-assigned this Aug 9, 2021
@bflad bflad closed this as completed in #94 Aug 10, 2021
bflad added a commit that referenced this issue Aug 10, 2021
Reference: #80

Each type now implements three separate and distinct comparison methods:

* `(T).Equal()`: performs deep type equality checks, including attribute/element types and whether attributes are optional or not.
* `(T).Is()`: performs shallow type equality checks, in that the root type is compared, but underlying attribute/element types are not.
* `(T).UsableAs()`: performs type conformance checks. This primarily checks if the target implements `DynamicPsuedoType` in a compatible manner.
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking-change This will impact or improve our compatibility posture
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants