aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-11-25 00:08:13 +0800
committerchriseth <c@ethdev.com>2015-11-26 22:37:55 +0800
commitcc2df5f9f2726f92bebe95e2a94afb6ba32c785c (patch)
treeb87aa2a8234eb622cdc57177abcb7c46c262399e /libsolidity/ast
parent2e4f4e3363586f3557bd36547d05a303d287015b (diff)
downloaddexon-solidity-cc2df5f9f2726f92bebe95e2a94afb6ba32c785c.tar.gz
dexon-solidity-cc2df5f9f2726f92bebe95e2a94afb6ba32c785c.tar.zst
dexon-solidity-cc2df5f9f2726f92bebe95e2a94afb6ba32c785c.zip
Invalidate cached members if scope changes.
Diffstat (limited to 'libsolidity/ast')
-rw-r--r--libsolidity/ast/Types.cpp3
-rw-r--r--libsolidity/ast/Types.h1
2 files changed, 3 insertions, 1 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index a4da5b13..96f44571 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -1787,7 +1787,7 @@ unsigned TypeType::sizeOnStack() const
MemberList const& TypeType::members(ContractDefinition const* _currentScope) const
{
// We need to lazy-initialize it because of recursive references.
- if (!m_members)
+ if (!m_members || m_cachedScope != _currentScope)
{
MemberList::MemberMap members;
if (m_actualType->category() == Category::Contract)
@@ -1818,6 +1818,7 @@ MemberList const& TypeType::members(ContractDefinition const* _currentScope) con
members.push_back(MemberList::Member(enumValue->name(), enumType));
}
m_members.reset(new MemberList(members));
+ m_cachedScope = _currentScope;
}
return *m_members;
}
diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h
index 0769ba39..f841a1be 100644
--- a/libsolidity/ast/Types.h
+++ b/libsolidity/ast/Types.h
@@ -941,6 +941,7 @@ private:
TypePointer m_actualType;
/// List of member types, will be lazy-initialized because of recursive references.
mutable std::unique_ptr<MemberList> m_members;
+ mutable ContractDefinition const* m_cachedScope = nullptr;
};