forked from vyperlang/vyper
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow using interface defs from imported modules (vyperlang#3725)
- add interface defs to ModuleT's exposed `get_type_members()` - slight refactor of ModuleT to have a special helper instead of dispatching to `self.interface`
- Loading branch information
1 parent
07ab92f
commit 5c2177b
Showing
7 changed files
with
60 additions
and
10 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
tests/functional/codegen/modules/test_interface_imports.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
def test_import_interface_types(make_input_bundle, get_contract): | ||
ifaces = """ | ||
interface IFoo: | ||
def foo() -> uint256: nonpayable | ||
""" | ||
|
||
foo_impl = """ | ||
import ifaces | ||
implements: ifaces.IFoo | ||
@external | ||
def foo() -> uint256: | ||
return block.number | ||
""" | ||
|
||
contract = """ | ||
import ifaces | ||
@external | ||
def test_foo(s: ifaces.IFoo) -> bool: | ||
assert s.foo() == block.number | ||
return True | ||
""" | ||
|
||
input_bundle = make_input_bundle({"ifaces.vy": ifaces}) | ||
|
||
foo = get_contract(foo_impl, input_bundle=input_bundle) | ||
c = get_contract(contract, input_bundle=input_bundle) | ||
|
||
assert c.test_foo(foo.address) is True |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,7 +90,7 @@ def foo(): nonpayable | |
""" | ||
implements: self.x | ||
""", | ||
StructureException, | ||
InvalidType, | ||
), | ||
( | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters