mirror of
https://github.com/vlang/v.git
synced 2025-09-12 17:07:11 -04:00
This commit is contained in:
parent
be0de59076
commit
067c5b6486
@ -191,7 +191,7 @@ pub mut:
|
||||
methods []Fn
|
||||
embeds []Type
|
||||
// `I1 is I2` conversions
|
||||
conversions map[int][]Type
|
||||
conversions shared map[int][]Type
|
||||
// generic interface support
|
||||
is_generic bool
|
||||
generic_types []Type
|
||||
|
@ -7598,10 +7598,12 @@ fn (mut g Gen) as_cast(node ast.AsCast) {
|
||||
g.write(')')
|
||||
|
||||
mut info := expr_type_sym.info as ast.Interface
|
||||
if node.typ !in info.conversions {
|
||||
left_variants := g.table.iface_types[expr_type_sym.name]
|
||||
right_variants := g.table.iface_types[sym.name]
|
||||
info.conversions[node.typ] = left_variants.filter(it in right_variants)
|
||||
lock info.conversions {
|
||||
if node.typ !in info.conversions {
|
||||
left_variants := g.table.iface_types[expr_type_sym.name]
|
||||
right_variants := g.table.iface_types[sym.name]
|
||||
info.conversions[node.typ] = left_variants.filter(it in right_variants)
|
||||
}
|
||||
}
|
||||
expr_type_sym.info = info
|
||||
} else if mut expr_type_sym.info is ast.Interface && node.expr_type != node.typ {
|
||||
|
@ -776,18 +776,19 @@ fn (mut g Gen) gen_interface_is_op(node ast.InfixExpr) {
|
||||
right_sym := g.table.sym(node.right_type)
|
||||
|
||||
mut info := left_sym.info as ast.Interface
|
||||
|
||||
common_variants := info.conversions[node.right_type] or {
|
||||
left_variants := g.table.iface_types[left_sym.name]
|
||||
right_variants := g.table.iface_types[right_sym.name]
|
||||
c := left_variants.filter(it in right_variants)
|
||||
info.conversions[node.right_type] = c
|
||||
c
|
||||
}
|
||||
left_sym.info = info
|
||||
if common_variants.len == 0 {
|
||||
g.write('false')
|
||||
return
|
||||
lock info.conversions {
|
||||
common_variants := info.conversions[node.right_type] or {
|
||||
left_variants := g.table.iface_types[left_sym.name]
|
||||
right_variants := g.table.iface_types[right_sym.name]
|
||||
c := left_variants.filter(it in right_variants)
|
||||
info.conversions[node.right_type] = c
|
||||
c
|
||||
}
|
||||
left_sym.info = info
|
||||
if common_variants.len == 0 {
|
||||
g.write('false')
|
||||
return
|
||||
}
|
||||
}
|
||||
g.write('I_${left_sym.cname}_is_I_${right_sym.cname}(')
|
||||
if node.left_type.is_ptr() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user