Skip to content

Commit

Permalink
sealed is also override
Browse files Browse the repository at this point in the history
  • Loading branch information
borisbat committed Dec 20, 2024
1 parent 2f216a3 commit e6deccf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/ast/ast_infer_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1927,6 +1927,17 @@ namespace das {
if ( decl.type && decl.type->isExprType() ) {
return;
}
if ( !st->parent && decl.classMethod && decl.type && decl.type->baseType==Type::autoinfer ) {
// if its field:auto = cast<auto>(@@fun) - we demote to @@fun; this is only possible when its sealed in the base class
if ( decl.init && decl.init->rtti_isCast() ) {
auto castExpr = static_pointer_cast<ExprCast>(decl.init);
if ( castExpr->castType && castExpr->castType->baseType==Type::autoinfer ) {
decl.init = castExpr->subexpr;
reportAstChanged();
return;
}
}
}
if ( decl.parentType ) {
auto pf = st->parent->findField(decl.name);
if ( !pf->type->isAutoOrAlias() ) {
Expand Down
2 changes: 1 addition & 1 deletion src/parser/parser_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ namespace das {
auto vars = new vector<VariableNameAndPosition>();
vars->emplace_back(VariableNameAndPosition{varName,"",func->at});
Expression * finit = new ExprAddr(func->at, inThisModule(func->name));
if ( ovr == OVERRIDE_OVERRIDE ) {
if ( ovr == OVERRIDE_OVERRIDE || ovr == OVERRIDE_SEALED ) {
finit = new ExprCast(func->at, finit, make_smart<TypeDecl>(Type::autoinfer));
}
VariableDeclaration * decl = new VariableDeclaration(
Expand Down

0 comments on commit e6deccf

Please sign in to comment.