Skip to content

Commit

Permalink
fix overrides by state variables
Browse files Browse the repository at this point in the history
  • Loading branch information
frangio committed Aug 19, 2021
1 parent 366a146 commit 5a74490
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.9

- Fix contracts that override a function through a public variable.

## 0.1.8

- Fix import paths on Windows.
Expand Down
10 changes: 7 additions & 3 deletions contracts/Test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@ interface Iface {
}

abstract contract Abs {
function _abstract() internal pure virtual returns (uint);
function abs() external view virtual returns (uint);
}

contract Concrete is Abs {
function _abstract() internal pure override returns (uint) {
contract Concrete1 is Abs {
function abs() public pure override returns (uint) {
return 42;
}
}

contract Concrete2 is Abs {
uint public override abs = 42;
}

abstract contract Parent1 {
constructor(uint x) {}

Expand Down
8 changes: 4 additions & 4 deletions src/core.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ Generated by [AVA](https://avajs.dev).
constructor() {}␊
}␊
contract XConcrete is Concrete {␊
contract XConcrete1 is Concrete1 {␊
constructor() {}␊
}␊
function x_abstract() external pure returns (uint256) {␊
return super._abstract();␊
}␊
contract XConcrete2 is Concrete2 {␊
constructor() {}␊
}␊
contract XParent1 is Parent1 {␊
Expand Down
Binary file modified src/core.test.ts.snap
Binary file not shown.
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function areFunctionsFullyImplemented(contract: ContractDefinition, contractMap:
const parents = contract.linearizedBaseContracts.map(id => mustGet(contractMap, id));
const abstractFunctionIds = new Set(parents.flatMap(p => [...findAll('FunctionDefinition', p)].filter(f => !f.implemented).map(f => f.id)));
for (const p of parents) {
for (const f of findAll('FunctionDefinition', p)) {
for (const f of findAll(['FunctionDefinition', 'VariableDeclaration'], p)) {
for (const b of f.baseFunctions ?? []) {
abstractFunctionIds.delete(b);
}
Expand Down

0 comments on commit 5a74490

Please sign in to comment.