Deprecate Scope::ScopeID(), replace with GetID()

This commit is contained in:
Jon Siwek 2020-05-27 16:36:14 -07:00
parent 8b6de5852c
commit b0c95e30d0
3 changed files with 9 additions and 5 deletions

View file

@ -881,7 +881,7 @@ function_ingredients::function_ingredients(IntrusivePtr<Scope> scope, IntrusiveP
inits = scope->GetInits();
this->scope = std::move(scope);
id = {NewRef{}, this->scope->ScopeID()};
id = this->scope->GetID();
const auto& attrs = this->scope->Attrs();

View file

@ -35,8 +35,12 @@ public:
IntrusivePtr<ID> Remove(std::string_view name);
[[deprecated("Remove in v4.1. Use GetID().")]]
ID* ScopeID() const { return scope_id.get(); }
const IntrusivePtr<ID>& GetID() const
{ return scope_id; }
const std::unique_ptr<std::vector<IntrusivePtr<Attr>>>& Attrs() const
{ return attrs; }

View file

@ -1414,21 +1414,21 @@ ReturnStmt::ReturnStmt(IntrusivePtr<Expr> arg_e)
{
Scope* s = current_scope();
if ( ! s || ! s->ScopeID() )
if ( ! s || ! s->GetID() )
{
Error("return statement outside of function/event");
return;
}
FuncType* ft = s->ScopeID()->GetType()->AsFuncType();
FuncType* ft = s->GetID()->GetType()->AsFuncType();
const auto& yt = ft->Yield();
if ( s->ScopeID()->DoInferReturnType() )
if ( s->GetID()->DoInferReturnType() )
{
if ( e )
{
ft->SetYieldType(e->GetType());
s->ScopeID()->SetInferReturnType(false);
s->GetID()->SetInferReturnType(false);
}
}