From 0bfdaa500af6ae1a480f6f6f417a6a12ada0a313 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 15 Jan 2019 00:14:10 +0100 Subject: Add code access dependency. --- libsolidity/analysis/TypeChecker.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 4cdfcc0c..ee5865f7 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -2100,9 +2100,20 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) { if (magicType->kind() == MagicType::Kind::ABI) annotation.isPure = true; - else if (magicType->kind() == MagicType::Kind::MetaType) - if (memberName == "creationCode" || memberName == "runtimeCode") - annotation.isPure = true; + else if (magicType->kind() == MagicType::Kind::MetaType && ( + memberName == "creationCode" || memberName == "runtimeCode" + )) + { + annotation.isPure = true; + m_scope->annotation().contractDependencies.insert( + &dynamic_cast(*magicType->typeArgument()).contractDefinition() + ); + if (contractDependenciesAreCyclic(*m_scope)) + m_errorReporter.typeError( + _memberAccess.location(), + "Circular reference for contract code access." + ); + } } return false; -- cgit v1.2.3