Don't consider contracts implicitly convertible to the type of super

- `super` for all intents and purposes behaves like a type and should be a TypeType rather than ContractType. We have an issue to fix it but it's a breaking change. Until then let's at least not treat other contracts as convertible to the ContractType that `super` represents.
This commit is contained in:
Kamil Śliwak
2020-09-08 00:29:44 +02:00
parent 7681c7dddf
commit 41bcb97e36
4 changed files with 89 additions and 1 deletions
+5 -1
View File
@@ -1569,11 +1569,15 @@ BoolResult ContractType::isImplicitlyConvertibleTo(Type const& _convertTo) const
return true;
if (_convertTo.category() == Category::Contract)
{
auto const& targetContractType = dynamic_cast<ContractType const&>(_convertTo);
if (targetContractType.isSuper())
return false;
auto const& bases = contractDefinition().annotation().linearizedBaseContracts;
return find(
bases.begin(),
bases.end(),
&dynamic_cast<ContractType const&>(_convertTo).contractDefinition()
&targetContractType.contractDefinition()
) != bases.end();
}
return false;