mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Change type of super to TypeType
This commit is contained in:
@@ -140,7 +140,7 @@ MagicVariableDeclaration const* GlobalContext::currentSuper() const
|
||||
{
|
||||
Type const* type = TypeProvider::emptyTuple();
|
||||
if (m_currentContract)
|
||||
type = TypeProvider::contract(*m_currentContract, true);
|
||||
type = TypeProvider::typeType(TypeProvider::contract(*m_currentContract, true));
|
||||
m_superPointer[m_currentContract] =
|
||||
make_shared<MagicVariableDeclaration>(magicVariableToID("super"), "super", type);
|
||||
}
|
||||
|
||||
@@ -2760,9 +2760,12 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
|
||||
);
|
||||
|
||||
if (!funType->bound())
|
||||
if (auto contractType = dynamic_cast<ContractType const*>(exprType))
|
||||
if (contractType->isSuper())
|
||||
if (auto typeType = dynamic_cast<TypeType const*>(exprType))
|
||||
{
|
||||
auto contractType = dynamic_cast<ContractType const*>(typeType->actualType());
|
||||
if (contractType && contractType->isSuper())
|
||||
requiredLookup = VirtualLookup::Super;
|
||||
}
|
||||
}
|
||||
|
||||
annotation.requiredLookup = requiredLookup;
|
||||
@@ -2837,8 +2840,13 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
|
||||
_memberAccess.location(),
|
||||
"\"runtimeCode\" is not available for contracts containing immutable variables."
|
||||
);
|
||||
|
||||
if (m_currentContract)
|
||||
if (accessedContractType.isSuper())
|
||||
m_errorReporter.typeError(
|
||||
3625_error,
|
||||
_memberAccess.location(),
|
||||
"\"creationCode\" and \"runtimeCode\" are not available for the \"super\" contract."
|
||||
);
|
||||
else if (m_currentContract)
|
||||
{
|
||||
// TODO in the same way as with ``new``,
|
||||
// this is not properly detecting creation-cycles if they go through
|
||||
|
||||
@@ -194,8 +194,8 @@ void ViewPureChecker::endVisit(Identifier const& _identifier)
|
||||
switch (magicVar->type()->category())
|
||||
{
|
||||
case Type::Category::Contract:
|
||||
solAssert(_identifier.name() == "this" || _identifier.name() == "super", "");
|
||||
if (!dynamic_cast<ContractType const&>(*magicVar->type()).isSuper())
|
||||
solAssert(_identifier.name() == "this", "");
|
||||
if (dynamic_cast<ContractType const*>(magicVar->type()))
|
||||
// reads the address
|
||||
mutability = StateMutability::View;
|
||||
break;
|
||||
@@ -440,4 +440,3 @@ void ViewPureChecker::endVisit(ModifierInvocation const& _modifier)
|
||||
else
|
||||
solAssert(dynamic_cast<ContractDefinition const*>(_modifier.name().annotation().referencedDeclaration), "");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user