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

Add isSubtype function for runtime values #1189

Merged
merged 8 commits into from
Oct 25, 2021
Merged

Add isSubtype function for runtime values #1189

merged 8 commits into from
Oct 25, 2021

Conversation

dsainati1
Copy link
Contributor

@dsainati1 dsainati1 commented Oct 22, 2021

Closes #473

Description

Adds a fun isSubtype(of otherType : Type) : Bool to runtime types which compares their static types and returns true if the receiver is a subtype of the argument and false if not. Note that unknown types (which have no static type) will return false if they are the receiver of the method or the argument, as it is illogical to check whether an unknown type is a supertype or subtype of anything else.


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@codecov-commenter
Copy link

codecov-commenter commented Oct 22, 2021

Codecov Report

Merging #1189 (863598e) into master (01ae3c2) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1189      +/-   ##
==========================================
+ Coverage   73.38%   73.39%   +0.01%     
==========================================
  Files         272      272              
  Lines       34584    34603      +19     
==========================================
+ Hits        25379    25398      +19     
  Misses       8032     8032              
  Partials     1173     1173              
Flag Coverage Δ
unittests 73.39% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
runtime/interpreter/value.go 79.13% <100.00%> (+0.06%) ⬆️
runtime/sema/meta_type.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 01ae3c2...863598e. Read the comment docs.

Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Nice work!

docs/language/run-time-types.md Outdated Show resolved Hide resolved
runtime/sema/meta_type.go Outdated Show resolved Hide resolved
runtime/sema/meta_type.go Outdated Show resolved Hide resolved
runtime/sema/meta_type.go Outdated Show resolved Hide resolved
runtime/sema/meta_type.go Outdated Show resolved Hide resolved
runtime/tests/checker/metatype_test.go Show resolved Hide resolved
runtime/tests/interpreter/metatype_test.go Show resolved Hide resolved
runtime/interpreter/value.go Outdated Show resolved Hide resolved
runtime/interpreter/value.go Show resolved Hide resolved
@dsainati1 dsainati1 requested a review from turbolent October 22, 2021 18:42
Copy link
Member

@SupunS SupunS left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Great work on your first PR! 👏 🥳

docs/language/run-time-types.md Outdated Show resolved Hide resolved
runtime/sema/meta_type.go Show resolved Hide resolved
runtime/sema/meta_type.go Outdated Show resolved Hide resolved
dsainati1 and others added 2 commits October 22, 2021 15:57
Co-authored-by: Bastian Müller <bastian@axiomzen.co>
Co-authored-by: Bastian Müller <bastian@axiomzen.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow subtype test of run-time types
4 participants