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

cgen: small interface conversion fix (#11229)

This commit is contained in:
spaceface 2021-08-18 12:47:57 +02:00 committed by GitHub
parent 7a3fe3ca70
commit 09e854c064
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View File

@ -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(')')

View File

@ -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(')')
}

View File

@ -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 {
}