protected:
// Apply the implicit type rules to this symbol.
void ApplyImplicitRules(Symbol &);
- const DeclTypeSpec *GetImplicitType(Symbol &);
+ const DeclTypeSpec *GetImplicitType(Symbol &, const Scope &);
bool ConvertToObjectEntity(Symbol &);
bool ConvertToProcEntity(Symbol &);
void ScopeHandler::ApplyImplicitRules(Symbol &symbol) {
if (NeedsType(symbol)) {
- if (const DeclTypeSpec * type{GetImplicitType(symbol)}) {
+ const Scope *scope{&symbol.owner()};
+ if (scope->IsGlobal()) {
+ scope = &currScope();
+ }
+ if (const DeclTypeSpec *
+ type{GetImplicitType(symbol, GetInclusiveScope(*scope))}) {
symbol.set(Symbol::Flag::Implicit);
symbol.SetType(*type);
return;
}
}
-const DeclTypeSpec *ScopeHandler::GetImplicitType(Symbol &symbol) {
- const auto *type{implicitRulesMap_->at(&GetInclusiveScope(symbol.owner()))
- .GetType(symbol.name())};
+const DeclTypeSpec *ScopeHandler::GetImplicitType(
+ Symbol &symbol, const Scope &scope) {
+ const auto *type{implicitRulesMap_->at(&scope).GetType(symbol.name())};
if (type) {
if (const DerivedTypeSpec * derived{type->AsDerived()}) {
// Resolve any forward-referenced derived type; a quick no-op else.