ethereum / solidity

Solidity, the Smart Contract Programming Language
https://soliditylang.org
GNU General Public License v3.0
23.12k stars 5.73k forks source link

Function selectors from inherited interfaces are not visible in parent interface #15157

Open mnusurov opened 4 months ago

mnusurov commented 4 months ago

Description

The following code fails to compile with:

TypeError: Member "b" not found or not visible after argument-dependent lookup in type(contract I2).

pragma solidity 0.8.26;

interface I1 {
    function b() external;
}

interface I2 is I1 {
    function a() external;
}

// ✅ Test 1 -- passes 
contract test_a {
    function a() external view returns (bytes4) {
        return I2.a.selector;
    }
}

// ❌ Test 1 -- should pass
contract test_b {
    function b() external view returns (bytes4) {
        return I2.b.selector;
    }
}

Why?

According to official v0.8.26 documentation,

Interfaces can inherit from other interfaces. This has the same rules as normal inheritance:

nikola-matic commented 4 months ago

Thanks for the report @mnusurov.