cgen: small interface conversion fix (#11229)
parent
7a3fe3ca70
commit
09e854c064
|
@ -6466,6 +6466,9 @@ fn (mut g Gen) as_cast(node ast.AsCast) {
|
|||
}
|
||||
} else if expr_type_sym.kind == .interface_ && sym.kind == .interface_ {
|
||||
g.write('I_${expr_type_sym.cname}_as_I_${sym.cname}(')
|
||||
if node.expr_type.is_ptr() {
|
||||
g.write('*')
|
||||
}
|
||||
g.expr(node.expr)
|
||||
g.write(')')
|
||||
|
||||
|
|
|
@ -448,6 +448,9 @@ fn (mut g Gen) gen_interface_is_op(node ast.InfixExpr) {
|
|||
return
|
||||
}
|
||||
g.write('I_${left_sym.cname}_is_I_${right_sym.cname}(')
|
||||
if node.left_type.is_ptr() {
|
||||
g.write('*')
|
||||
}
|
||||
g.expr(node.left)
|
||||
g.write(')')
|
||||
}
|
||||
|
|
|
@ -21,6 +21,15 @@ fn draw(w Widget) {
|
|||
}
|
||||
}
|
||||
|
||||
fn draw_ref(w &Widget) {
|
||||
if w is ResizableWidget {
|
||||
rw := w as ResizableWidget
|
||||
assert rw.resize(10, 20) == 200
|
||||
} else {
|
||||
assert false
|
||||
}
|
||||
}
|
||||
|
||||
// implements Widget, but not ResizableWidget
|
||||
struct WidgetA {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue