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

v.ast: allow for fn f()&IAbc{return voidptr(0)} with no additional voidptr implicit conversions to compile

This commit is contained in:
Delyan Angelov 2021-06-16 11:07:04 +03:00
parent 862c4cf371
commit 69ce8baefd
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 27 additions and 0 deletions

View File

@ -1122,6 +1122,9 @@ fn (mut table Table) does_type_implement_interface(typ Type, inter_typ Type) boo
return false
}
inter_sym.info.types << utyp
if !inter_sym.info.types.contains(voidptr_type) {
inter_sym.info.types << voidptr_type
}
}
return true
}

View File

@ -0,0 +1,24 @@
interface IAbc {
name string
xyz()
}
fn f(i &IAbc) string {
return '$i'
}
struct Abc {
name string
x int = 123
}
fn (a Abc) xyz() {}
fn resource__null() &IAbc {
return voidptr(0)
}
fn test_fn_returning_voidptr_casted_as_interface_works() {
pi := resource__null()
assert f(pi) == '&IAbc(0)'
}