cgen: fix interface only declare with optional method (#10546)

pull/10552/head
yuyi 2021-06-23 20:14:08 +08:00 committed by GitHub
parent 500b48788e
commit e8a1e9d88f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -1332,6 +1332,12 @@ fn (mut g Gen) stmt(node ast.Stmt) {
ast.Import {}
ast.InterfaceDecl {
// definitions are sorted and added in write_types
for method in node.methods {
if method.return_type.has_flag(.optional) {
// Register an optional if it's not registered yet
g.register_optional(method.return_type)
}
}
}
ast.Module {
// g.is_builtin_mod = node.name == 'builtin'

View File

@ -0,0 +1,8 @@
interface Message {
serialize() ?[]byte
}
fn test_interface_only_decl_with_optional() {
println('test interface')
assert true
}