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