diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index f18882c03..2d2d97aff 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -40,6 +40,7 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i node @contract.def node @contract.members node @contract.type_members + node @contract.super_scope edge @contract.lexical_scope -> @contract.members edge @contract.lexical_scope -> @contract.type_members @@ -283,9 +284,23 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i edge def -> type_member edge type_member -> @contract.type_members + + ;; Define "super" effectively as if it was a state variable of a type connected by our super_scope + ;; super_scope will later connect to the base contract defs directly + node super + attr (super) pop_symbol = "super" + + node super_typeof + attr (super_typeof) push_symbol = "@typeof" + + edge super -> super_typeof + edge super_typeof -> @contract.super_scope + + ;; Finally make "super" available in the contract's lexical scope for function bodies to use + edge @contract.lexical_scope -> super } -@contract [ContractDefinition [InheritanceSpecifier [InheritanceTypes [InheritanceType +@contract [ContractDefinition [InheritanceSpecifier [InheritanceTypes @type [InheritanceType @type_name [IdentifierPath] ]]]] { ;; Resolve contract bases names through the parent scope of the contract (aka @@ -309,6 +324,12 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i edge @contract.type_members -> type_member edge type_member -> @type_name.right + + ;; The base contract defs are directly accesible through our special super scope + edge @contract.super_scope -> @type_name.right + ;; Precedence order for bases defined from right to left (ie. rightmost base has higher precedence) + let p = (plus 1 (named-child-index @type)) + attr (@contract.super_scope -> @type_name.right) precedence = p } @interface [InterfaceDefinition @name name: [Identifier]] { @@ -484,6 +505,17 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i edge @library.members -> @function.def } +;;; Function modifiers + +@contract [ContractDefinition [ContractMembers [ContractMember + @_function [FunctionDefinition [FunctionAttributes [FunctionAttribute + [OverrideSpecifier [OverridePathsDeclaration [OverridePaths + @base_ident [IdentifierPath] + ]]] + ]]] +]]] { + edge @base_ident.left -> @contract.parent_scope +} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/bindings/generated/binding_rules.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/bindings/generated/binding_rules.rs index f51f69f43..0c2d9ba88 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/bindings/generated/binding_rules.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/bindings/generated/binding_rules.rs @@ -45,6 +45,7 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i node @contract.def node @contract.members node @contract.type_members + node @contract.super_scope edge @contract.lexical_scope -> @contract.members edge @contract.lexical_scope -> @contract.type_members @@ -288,9 +289,23 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i edge def -> type_member edge type_member -> @contract.type_members + + ;; Define "super" effectively as if it was a state variable of a type connected by our super_scope + ;; super_scope will later connect to the base contract defs directly + node super + attr (super) pop_symbol = "super" + + node super_typeof + attr (super_typeof) push_symbol = "@typeof" + + edge super -> super_typeof + edge super_typeof -> @contract.super_scope + + ;; Finally make "super" available in the contract's lexical scope for function bodies to use + edge @contract.lexical_scope -> super } -@contract [ContractDefinition [InheritanceSpecifier [InheritanceTypes [InheritanceType +@contract [ContractDefinition [InheritanceSpecifier [InheritanceTypes @type [InheritanceType @type_name [IdentifierPath] ]]]] { ;; Resolve contract bases names through the parent scope of the contract (aka @@ -314,6 +329,12 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i edge @contract.type_members -> type_member edge type_member -> @type_name.right + + ;; The base contract defs are directly accesible through our special super scope + edge @contract.super_scope -> @type_name.right + ;; Precedence order for bases defined from right to left (ie. rightmost base has higher precedence) + let p = (plus 1 (named-child-index @type)) + attr (@contract.super_scope -> @type_name.right) precedence = p } @interface [InterfaceDefinition @name name: [Identifier]] { @@ -489,6 +510,17 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i edge @library.members -> @function.def } +;;; Function modifiers + +@contract [ContractDefinition [ContractMembers [ContractMember + @_function [FunctionDefinition [FunctionAttributes [FunctionAttribute + [OverrideSpecifier [OverridePathsDeclaration [OverridePaths + @base_ident [IdentifierPath] + ]]] + ]]] +]]] { + edge @base_ident.left -> @contract.parent_scope +} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/contracts.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/contracts.rs index aedc24d59..cf6382594 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/contracts.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/contracts.rs @@ -9,6 +9,11 @@ fn inheritance() -> Result<()> { run("contracts", "inheritance") } +#[test] +fn virtual_methods() -> Result<()> { + run("contracts", "virtual_methods") +} + #[test] fn visibility() -> Result<()> { run("contracts", "visibility") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/contracts.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/contracts.rs index fb5cafb65..e393075c0 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/contracts.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/contracts.rs @@ -9,6 +9,16 @@ fn inheritance() -> Result<()> { run("contracts", "inheritance") } +#[test] +fn super_scope() -> Result<()> { + run("contracts", "super_scope") +} + +#[test] +fn virtual_methods() -> Result<()> { + run("contracts", "virtual_methods") +} + #[test] fn visibility() -> Result<()> { run("contracts", "visibility") diff --git a/crates/solidity/testing/snapshots/bindings_assertions/contracts/virtual_methods.sol b/crates/solidity/testing/snapshots/bindings_assertions/contracts/virtual_methods.sol new file mode 100644 index 000000000..343684487 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_assertions/contracts/virtual_methods.sol @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +contract A { + // ^def:dummy -- to have at least one assertion in 0.4.11 + function foo() public pure virtual returns (string memory) { + // ^def:1 + return "A"; + } +} + +contract B is A { + function foo() public pure virtual override returns (string memory) { + // ^def:2 + return "B"; + } +} + +contract C is A { + function foo() public pure virtual override returns (string memory) { + // ^def:3 + return "C"; + } +} + +contract D is B, C { + // D.foo() returns "C" + function foo() public pure override(B, C) returns (string memory) { + return super.foo(); + // ^ref:3 (>=0.6.0) + } +} + +contract E is C, B { + // E.foo() returns "B" + function foo() public pure override(C, B) returns (string memory) { + return super.foo(); + // ^ref:2 (>=0.6.0) + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.4.11-failure.txt new file mode 100644 index 000000000..3502c5219 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.4.11-failure.txt @@ -0,0 +1,41 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected OpenBrace or ReturnsKeyword or Semicolon. + ╭─[input.sol:5:27] + │ + 5 │ ╭─▶ function foo() public pure virtual returns (string memory) { + ┆ ┆ + 7 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +Error: Expected OpenBrace or ReturnsKeyword or Semicolon. + ╭─[input.sol:12:27] + │ + 12 │ ╭─▶ function foo() public pure virtual override(A) returns (string memory) { + ┆ ┆ + 14 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 4 │ contract A { + │ ┬ + │ ╰── def: 1 + 5 │ function foo() public pure virtual returns (string memory) { + │ ─┬─ + │ ╰─── def: 2 + │ + 10 │ contract B is A { + │ ┬ ┬ + │ ╰─────── def: 3 + │ │ + │ ╰── ref: 1 + │ + 12 │ function foo() public pure virtual override(A) returns (string memory) { + │ ─┬─ + │ ╰─── def: 4 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.4.16-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.4.16-success.txt new file mode 100644 index 000000000..20de8bab8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.4.16-success.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 4 │ contract A { + │ ┬ + │ ╰── def: 1 + 5 │ function foo() public pure virtual returns (string memory) { + │ ─┬─ ───┬─── + │ ╰───────────────────────── def: 2 + │ │ + │ ╰───── unresolved + │ + 10 │ contract B is A { + │ ┬ ┬ + │ ╰─────── def: 3 + │ │ + │ ╰── ref: 1 + │ + 12 │ function foo() public pure virtual override(A) returns (string memory) { + │ ─┬─ ───┬─── ────┬─── ┬ + │ ╰──────────────────────────────────── def: 4 + │ │ │ │ + │ ╰──────────────── unresolved + │ │ │ + │ ╰─────── unresolved + │ │ + │ ╰── unresolved + 13 │ return super.foo(); + │ ──┬── ─┬─ + │ ╰──────── unresolved + │ │ + │ ╰─── ref: 2 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.5.0-failure.txt new file mode 100644 index 000000000..c2732ac7c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.5.0-failure.txt @@ -0,0 +1,36 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected OpenBrace or ReturnsKeyword or Semicolon. + ╭─[input.sol:12:40] + │ + 12 │ ╭─▶ function foo() public pure virtual override(A) returns (string memory) { + ┆ ┆ + 14 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 4 │ contract A { + │ ┬ + │ ╰── def: 1 + 5 │ function foo() public pure virtual returns (string memory) { + │ ─┬─ ───┬─── + │ ╰───────────────────────── def: 2 + │ │ + │ ╰───── unresolved + │ + 10 │ contract B is A { + │ ┬ ┬ + │ ╰─────── def: 3 + │ │ + │ ╰── ref: 1 + │ + 12 │ function foo() public pure virtual override(A) returns (string memory) { + │ ─┬─ ───┬─── + │ ╰───────────────────────── def: 4 + │ │ + │ ╰───── unresolved +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.6.0-success.txt new file mode 100644 index 000000000..f23fed545 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.6.0-success.txt @@ -0,0 +1,29 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 4 │ contract A { + │ ┬ + │ ╰── def: 1 + 5 │ function foo() public pure virtual returns (string memory) { + │ ─┬─ + │ ╰─── def: 2 + │ + 10 │ contract B is A { + │ ┬ ┬ + │ ╰─────── def: 3 + │ │ + │ ╰── ref: 1 + │ + 12 │ function foo() public pure virtual override(A) returns (string memory) { + │ ─┬─ ┬ + │ ╰──────────────────────────────────── def: 4 + │ │ + │ ╰── ref: 1 + 13 │ return super.foo(); + │ ──┬── ─┬─ + │ ╰──────── unresolved + │ │ + │ ╰─── ref: 2 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/input.sol new file mode 100644 index 000000000..b8166044d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/input.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +contract A { + function foo() public pure virtual returns (string memory) { + return "A"; + } +} + +contract B is A { + // A super; + function foo() public pure virtual override(A) returns (string memory) { + return super.foo(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.4.11-failure.txt new file mode 100644 index 000000000..3c0c865a6 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.4.11-failure.txt @@ -0,0 +1,79 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected OpenBrace or ReturnsKeyword or Semicolon. + ╭─[input.sol:5:27] + │ + 5 │ ╭─▶ function foo() public pure virtual returns (string memory) { + ┆ ┆ + 7 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +Error: Expected OpenBrace or ReturnsKeyword or Semicolon. + ╭─[input.sol:11:27] + │ + 11 │ ╭─▶ function foo() public pure virtual override(A) returns (string memory) { + ┆ ┆ + 13 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +────╯ +Error: Expected OpenBrace or ReturnsKeyword or Semicolon. + ╭─[input.sol:17:27] + │ + 17 │ ╭─▶ function foo() public pure virtual override returns (string memory) { + ┆ ┆ + 19 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +────╯ +Error: Expected OpenBrace or ReturnsKeyword or Semicolon. + ╭─[input.sol:24:27] + │ + 24 │ ╭─▶ function foo() public pure override(B, C) returns (string memory) { + ┆ ┆ + 26 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 4 │ contract A { + │ ┬ + │ ╰── def: 1 + 5 │ function foo() public pure virtual returns (string memory) { + │ ─┬─ + │ ╰─── def: 2 + │ + 10 │ contract B is A { + │ ┬ ┬ + │ ╰─────── def: 3 + │ │ + │ ╰── ref: 1 + 11 │ function foo() public pure virtual override(A) returns (string memory) { + │ ─┬─ + │ ╰─── def: 4 + │ + 16 │ contract C is A { + │ ┬ ┬ + │ ╰─────── def: 5 + │ │ + │ ╰── ref: 1 + 17 │ function foo() public pure virtual override returns (string memory) { + │ ─┬─ + │ ╰─── def: 6 + │ + 22 │ contract D is B, C { + │ ┬ ┬ ┬ + │ ╰────────── def: 7 + │ │ │ + │ ╰───── ref: 3 + │ │ + │ ╰── ref: 5 + │ + 24 │ function foo() public pure override(B, C) returns (string memory) { + │ ─┬─ + │ ╰─── def: 8 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.4.16-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.4.16-success.txt new file mode 100644 index 000000000..93bb1877d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.4.16-success.txt @@ -0,0 +1,65 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 4 │ contract A { + │ ┬ + │ ╰── def: 1 + 5 │ function foo() public pure virtual returns (string memory) { + │ ─┬─ ───┬─── + │ ╰───────────────────────── def: 2 + │ │ + │ ╰───── unresolved + │ + 10 │ contract B is A { + │ ┬ ┬ + │ ╰─────── def: 3 + │ │ + │ ╰── ref: 1 + 11 │ function foo() public pure virtual override(A) returns (string memory) { + │ ─┬─ ───┬─── ────┬─── ┬ + │ ╰──────────────────────────────────── def: 4 + │ │ │ │ + │ ╰──────────────── unresolved + │ │ │ + │ ╰─────── unresolved + │ │ + │ ╰── unresolved + │ + 16 │ contract C is A { + │ ┬ ┬ + │ ╰─────── def: 5 + │ │ + │ ╰── ref: 1 + 17 │ function foo() public pure virtual override returns (string memory) { + │ ─┬─ ───┬─── ────┬─── + │ ╰────────────────────────────────── def: 6 + │ │ │ + │ ╰────────────── unresolved + │ │ + │ ╰───── unresolved + │ + 22 │ contract D is B, C { + │ ┬ ┬ ┬ + │ ╰────────── def: 7 + │ │ │ + │ ╰───── ref: 3 + │ │ + │ ╰── ref: 5 + │ + 24 │ function foo() public pure override(B, C) returns (string memory) { + │ ─┬─ ────┬─── ┬ ┬ + │ ╰─────────────────────────────── def: 8 + │ │ │ │ + │ ╰────────── unresolved + │ │ │ + │ ╰───── unresolved + │ │ + │ ╰── unresolved + 25 │ return super.foo(); + │ ──┬── ─┬─ + │ ╰──────── unresolved + │ │ + │ ╰─── ref: 2 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.5.0-failure.txt new file mode 100644 index 000000000..e3235a738 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.5.0-failure.txt @@ -0,0 +1,76 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected OpenBrace or ReturnsKeyword or Semicolon. + ╭─[input.sol:11:40] + │ + 11 │ ╭─▶ function foo() public pure virtual override(A) returns (string memory) { + ┆ ┆ + 13 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +────╯ +Error: Expected OpenBrace or ReturnsKeyword or Semicolon. + ╭─[input.sol:17:40] + │ + 17 │ ╭─▶ function foo() public pure virtual override returns (string memory) { + ┆ ┆ + 19 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +────╯ +Error: Expected OpenBrace or ReturnsKeyword or Semicolon. + ╭─[input.sol:24:32] + │ + 24 │ ╭─▶ function foo() public pure override(B, C) returns (string memory) { + ┆ ┆ + 26 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 4 │ contract A { + │ ┬ + │ ╰── def: 1 + 5 │ function foo() public pure virtual returns (string memory) { + │ ─┬─ ───┬─── + │ ╰───────────────────────── def: 2 + │ │ + │ ╰───── unresolved + │ + 10 │ contract B is A { + │ ┬ ┬ + │ ╰─────── def: 3 + │ │ + │ ╰── ref: 1 + 11 │ function foo() public pure virtual override(A) returns (string memory) { + │ ─┬─ ───┬─── + │ ╰───────────────────────── def: 4 + │ │ + │ ╰───── unresolved + │ + 16 │ contract C is A { + │ ┬ ┬ + │ ╰─────── def: 5 + │ │ + │ ╰── ref: 1 + 17 │ function foo() public pure virtual override returns (string memory) { + │ ─┬─ ───┬─── + │ ╰───────────────────────── def: 6 + │ │ + │ ╰───── unresolved + │ + 22 │ contract D is B, C { + │ ┬ ┬ ┬ + │ ╰────────── def: 7 + │ │ │ + │ ╰───── ref: 3 + │ │ + │ ╰── ref: 5 + │ + 24 │ function foo() public pure override(B, C) returns (string memory) { + │ ─┬─ + │ ╰─── def: 8 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.6.0-success.txt new file mode 100644 index 000000000..4051530d3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.6.0-success.txt @@ -0,0 +1,53 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 4 │ contract A { + │ ┬ + │ ╰── def: 1 + 5 │ function foo() public pure virtual returns (string memory) { + │ ─┬─ + │ ╰─── def: 2 + │ + 10 │ contract B is A { + │ ┬ ┬ + │ ╰─────── def: 3 + │ │ + │ ╰── ref: 1 + 11 │ function foo() public pure virtual override(A) returns (string memory) { + │ ─┬─ ┬ + │ ╰──────────────────────────────────── def: 4 + │ │ + │ ╰── ref: 1 + │ + 16 │ contract C is A { + │ ┬ ┬ + │ ╰─────── def: 5 + │ │ + │ ╰── ref: 1 + 17 │ function foo() public pure virtual override returns (string memory) { + │ ─┬─ + │ ╰─── def: 6 + │ + 22 │ contract D is B, C { + │ ┬ ┬ ┬ + │ ╰────────── def: 7 + │ │ │ + │ ╰───── ref: 3 + │ │ + │ ╰── ref: 5 + │ + 24 │ function foo() public pure override(B, C) returns (string memory) { + │ ─┬─ ┬ ┬ + │ ╰─────────────────────────────── def: 8 + │ │ │ + │ ╰───── ref: 3 + │ │ + │ ╰── ref: 5 + 25 │ return super.foo(); + │ ──┬── ─┬─ + │ ╰──────── unresolved + │ │ + │ ╰─── ref: 2 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/input.sol new file mode 100644 index 000000000..e9d43642c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/input.sol @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +contract A { + function foo() public pure virtual returns (string memory) { + return "A"; + } +} + +contract B is A { + function foo() public pure virtual override(A) returns (string memory) { + return "B"; + } +} + +contract C is A { + function foo() public pure virtual override returns (string memory) { + return "C"; + } +} + +contract D is B, C { + // D.foo() returns "C" + function foo() public pure override(B, C) returns (string memory) { + return super.foo(); + } +}