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:
parent
862c4cf371
commit
69ce8baefd
@ -1122,6 +1122,9 @@ fn (mut table Table) does_type_implement_interface(typ Type, inter_typ Type) boo
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
inter_sym.info.types << utyp
|
inter_sym.info.types << utyp
|
||||||
|
if !inter_sym.info.types.contains(voidptr_type) {
|
||||||
|
inter_sym.info.types << voidptr_type
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -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)'
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user