-
Notifications
You must be signed in to change notification settings - Fork 140
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
Replace IsSubType
check with IsSameTypeKind
check where necessary
#1032
Conversation
IsSubType
check with IsSameTypeKind
check where necessary
Codecov Report
@@ Coverage Diff @@
## master #1032 +/- ##
=======================================
Coverage 77.28% 77.29%
=======================================
Files 274 274
Lines 35414 35401 -13
=======================================
- Hits 27371 27362 -9
+ Misses 6958 6955 -3
+ Partials 1085 1084 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
1f9a426
to
1709c9f
Compare
65c2749
to
c090eef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Thank you for fixing this! 👏
Do we have a way of auditing the rest of the code for cases where IsSameTypeKind
should be used instead of IsSubType
? Also, maybe we can document a guideline for future code?
c090eef
to
0de4ee2
Compare
0de4ee2
to
e6be268
Compare
Cadence Benchstat comparisonThis branch with compared with the base branch onflow:master commit 424f814 Results
|
I searched all the usages and replaced them where necessary. Unfortunately, this has to be done manually, can't think of a way to automate this/ audit with a test case. The general rule is:
I had already added some comments to the newly added mehtod. Also added a note on the old |
@SupunS Nice! Could we keep this comment/guideline somewhere in the codebase? Maybe as a comment somewhere, or in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! 👏
// However, to check if a type *strictly* belongs to a certain category, then consider | ||
// using `IsSameTypeKind` method. e.g: "Is type `T` an Integer type?". Using this method | ||
// for the later use-case may produce incorrect results. | ||
// * IsSubType() - To check the assignability. e.g: Is argument type T is a sub-type | ||
// of parameter type R. This is the more frequent use-case. | ||
// * IsSameTypeKind() - To check if a type strictly belongs to a certain category. e.g: Is the | ||
// expression type T is any of the integer types, but nothing else. | ||
// Another way to check is, asking the question of "if the subType is Never, | ||
// should the check still pass?". A common code-smell for potential incorrect | ||
// usage is, using IsSubType() method with a constant/pre-defined superType. | ||
// e.g: IsSubType(<<someType>>, FixedPointType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨ 👏
Closes #1031
Description
Never
as 'not' belongs to the same kind.master
branchFiles changed
in the Github PR explorer