1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker, cgen: allow implementing an interface with an embedded struct (#9042)

This commit is contained in:
spaceface
2021-03-01 21:47:00 +01:00
committed by GitHub
parent 65900e55e3
commit 2b53992c01
4 changed files with 68 additions and 4 deletions

View File

@@ -305,3 +305,28 @@ fn animal_match(a Animal) {
}
}
*/
interface II {
mut:
my_field int
}
struct AA {
BB
}
struct BB {
pad [10]byte
mut:
my_field int
}
fn main() {
mut aa := AA{}
mut ii := II(aa)
assert ii.my_field == 0
aa.my_field = 123
assert ii.my_field == 123
ii.my_field = 1234
assert aa.my_field == 1234
}