add parameter allow_no_constructor to the function register_top_level

This commit is contained in:
z78078 2022-07-06 14:11:38 +08:00
parent 7f816bb01c
commit 8c26f186b5
1 changed files with 2 additions and 1 deletions

View File

@ -164,6 +164,7 @@ impl TopLevelComposer {
ast: ast::Stmt<()>,
resolver: Option<Arc<dyn SymbolResolver + Send + Sync>>,
mod_path: String,
allow_no_constructor: bool,
) -> Result<(StrRef, DefinitionId, Option<Type>), String> {
let defined_names = &mut self.defined_names;
match &ast.node {
@ -298,7 +299,7 @@ impl TopLevelComposer {
self.definition_ast_list.push((def, Some(ast)));
}
let result_ty = if contains_constructor { Some(constructor_ty) } else { None };
let result_ty = if allow_no_constructor || contains_constructor { Some(constructor_ty) } else { None };
Ok((class_name, DefinitionId(class_def_id), result_ty))
}