}
}
-const Scope *Scope::FindScope(const parser::CharBlock &source) const {
+const Scope *Scope::FindScope(parser::CharBlock source) const {
+ return const_cast<const Scope *>(
+ const_cast<Scope *>(this)->FindScope(source));
+}
+
+Scope *Scope::FindScope(parser::CharBlock source) {
if (!sourceRange_.Contains(source)) {
return nullptr;
}
- for (const auto &child : children_) {
- if (const auto *scope{child.FindScope(source)}) {
+ for (auto &child : children_) {
+ if (auto *scope{child.FindScope(source)}) {
return scope;
}
}
const parser::CharBlock &sourceRange() const { return sourceRange_; }
void AddSourceRange(const parser::CharBlock &);
// Find the smallest scope under this one that contains source
- const Scope *FindScope(const parser::CharBlock &) const;
+ const Scope *FindScope(parser::CharBlock) const;
+ Scope *FindScope(parser::CharBlock);
// Attempts to find a match for a derived type instance
const DeclTypeSpec *FindInstantiatedDerivedType(const DerivedTypeSpec &,
(warningsAreErrors_ || messages_.AnyFatalError());
}
-const Scope &SemanticsContext::FindScope(
- const parser::CharBlock &source) const {
- if (const auto *scope{globalScope_.FindScope(source)}) {
+const Scope &SemanticsContext::FindScope(parser::CharBlock source) const {
+ return const_cast<const Scope &>(
+ const_cast<SemanticsContext *>(this)->FindScope(source));
+}
+
+Scope &SemanticsContext::FindScope(parser::CharBlock source) {
+ if (auto *scope{globalScope_.FindScope(source)}) {
return *scope;
} else {
common::die("invalid source location");
return messages_.Say(std::move(msg));
}
- const Scope &FindScope(const parser::CharBlock &) const;
+ const Scope &FindScope(parser::CharBlock) const;
+ Scope &FindScope(parser::CharBlock);
private:
const common::IntrinsicTypeDefaultKinds &defaultKinds_;