mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix qualified modifier lookup.
This commit is contained in:
parent
3957fb8191
commit
e64fd99fb5
@ -1301,11 +1301,16 @@ void ContractCompiler::appendModifierOrFunctionCode()
|
||||
appendModifierOrFunctionCode();
|
||||
else
|
||||
{
|
||||
solAssert(*modifierInvocation->name().annotation().requiredLookup == VirtualLookup::Virtual, "");
|
||||
|
||||
ModifierDefinition const& modifier = dynamic_cast<ModifierDefinition const&>(
|
||||
ModifierDefinition const& referencedModifier = dynamic_cast<ModifierDefinition const&>(
|
||||
*modifierInvocation->name().annotation().referencedDeclaration
|
||||
).resolveVirtual(m_context.mostDerivedContract());
|
||||
);
|
||||
VirtualLookup lookup = *modifierInvocation->name().annotation().requiredLookup;
|
||||
solAssert(lookup == VirtualLookup::Virtual || lookup == VirtualLookup::Static, "");
|
||||
ModifierDefinition const& modifier =
|
||||
lookup == VirtualLookup::Virtual ?
|
||||
referencedModifier.resolveVirtual(m_context.mostDerivedContract()) :
|
||||
referencedModifier;
|
||||
|
||||
CompilerContext::LocationSetter locationSetter(m_context, modifier);
|
||||
std::vector<ASTPointer<Expression>> const& modifierArguments =
|
||||
modifierInvocation->arguments() ? *modifierInvocation->arguments() : std::vector<ASTPointer<Expression>>();
|
||||
|
@ -0,0 +1,22 @@
|
||||
contract A {
|
||||
uint public x = 7;
|
||||
modifier m virtual { x = 2; _; }
|
||||
}
|
||||
contract C is A {
|
||||
modifier m override { x = 1; _; }
|
||||
|
||||
function f() public A.m returns (uint) {
|
||||
return 9;
|
||||
}
|
||||
function g() public m returns (uint) {
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// x() -> 7
|
||||
// f() -> 9
|
||||
// x() -> 2
|
||||
// g() -> 0x0a
|
||||
// x() -> 1
|
||||
// f() -> 9
|
||||
// x() -> 2
|
@ -0,0 +1,25 @@
|
||||
==== Source: a ====
|
||||
import "a" as M;
|
||||
contract C {
|
||||
uint public x;
|
||||
modifier m { x = 1; _; }
|
||||
|
||||
function f() public M.M.C.m returns (uint t, uint r) {
|
||||
t = x;
|
||||
x = 3;
|
||||
r = 9;
|
||||
}
|
||||
function g() public m returns (uint t, uint r) {
|
||||
t = x;
|
||||
x = 4;
|
||||
r = 10;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// x() -> 0x00
|
||||
// f() -> 1, 9
|
||||
// x() -> 3
|
||||
// g() -> 1, 0x0a
|
||||
// x() -> 4
|
||||
// f() -> 1, 9
|
||||
// x() -> 3
|
Loading…
Reference in New Issue
Block a user