-
-
Notifications
You must be signed in to change notification settings - Fork 918
feat[lang]: make interfaces subtypes of address
#5228
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -439,6 +439,12 @@ | |
| node, | ||
| ) | ||
|
|
||
| def compare_type(self, other): | ||
| from vyper.semantics.types.module import InterfaceT | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will be solved once we refactor |
||
|
|
||
| # interfaces can be widened to addresses | ||
| return isinstance(other, InterfaceT) or super().compare_type(other) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This subtype hook makes an individual interface acceptable where Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This only teaches direct expected-type checks that an interface is assignable to Useful? React with 👍 / 👎. |
||
|
|
||
|
|
||
| # type for "self" | ||
| # refactoring note: it might be best for this to be a ModuleT actually | ||
|
|
||
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.
With the getter override removed here,
foo: public(IERC20)now has a getter return type ofIERC20, soexternal_interface/interfaceoutput printsdef foo() -> IERC20without also emitting the import or interface definition needed to resolveIERC20. That regresses the common use case where generated interface output is consumed as a standalone.vyi; before this change the same getter printed-> addressand remained self-contained. Please keep generated interface text self-contained, e.g. by rendering public interface getter returns as their ABIaddresstype or by emitting the required interface definition/import.Useful? React with 👍 / 👎.