From f997e1337753811bddbcac6ce5306243e195da54 Mon Sep 17 00:00:00 2001 From: i582 <51853996+i582@users.noreply.github.com> Date: Tue, 14 Jan 2025 01:11:09 +0400 Subject: [PATCH 01/11] feat(types): add check if overridden functions have super function Fixes #1022 --- .../resolveDescriptors.spec.ts.snap | 5325 +++++++++++++++++ src/types/resolveDescriptors.ts | 57 +- ...-function-in-contract-from-base-trait.tact | 7 + ...on-in-contract-with-multi-inheritance.tact | 12 + ...ction-in-contract-without-inheritance.tact | 5 + ...for-non-existing-function-in-contract.tact | 6 + ...ing-function-in-trait-from-base-trait.tact | 7 + ...ction-in-trait-with-multi-inheritance.tact | 12 + ...function-in-trait-without-inheritance.tact | 5 + ...de-for-non-existing-function-in-trait.tact | 6 + ...-function-in-contract-from-base-trait.tact | 7 + ...ith-multi-inheritance-from-base-trait.tact | 14 + ...on-in-contract-with-multi-inheritance.tact | 10 + ...ction-in-contract-without-inheritance.tact | 5 + ...for-non-existing-function-in-contract.tact | 8 + ...ing-function-in-trait-from-base-trait.tact | 7 + ...ith-multi-inheritance-from-base-trait.tact | 14 + ...ction-in-trait-with-multi-inheritance.tact | 10 + ...function-in-trait-without-inheritance.tact | 5 + ...de-for-non-existing-function-in-trait.tact | 8 + 20 files changed, 5515 insertions(+), 15 deletions(-) create mode 100644 src/types/test-failed/override-for-non-existing-function-in-contract-from-base-trait.tact create mode 100644 src/types/test-failed/override-for-non-existing-function-in-contract-with-multi-inheritance.tact create mode 100644 src/types/test-failed/override-for-non-existing-function-in-contract-without-inheritance.tact create mode 100644 src/types/test-failed/override-for-non-existing-function-in-contract.tact create mode 100644 src/types/test-failed/override-for-non-existing-function-in-trait-from-base-trait.tact create mode 100644 src/types/test-failed/override-for-non-existing-function-in-trait-with-multi-inheritance.tact create mode 100644 src/types/test-failed/override-for-non-existing-function-in-trait-without-inheritance.tact create mode 100644 src/types/test-failed/override-for-non-existing-function-in-trait.tact create mode 100644 src/types/test/override-for-non-existing-function-in-contract-from-base-trait.tact create mode 100644 src/types/test/override-for-non-existing-function-in-contract-with-multi-inheritance-from-base-trait.tact create mode 100644 src/types/test/override-for-non-existing-function-in-contract-with-multi-inheritance.tact create mode 100644 src/types/test/override-for-non-existing-function-in-contract-without-inheritance.tact create mode 100644 src/types/test/override-for-non-existing-function-in-contract.tact create mode 100644 src/types/test/override-for-non-existing-function-in-trait-from-base-trait.tact create mode 100644 src/types/test/override-for-non-existing-function-in-trait-with-multi-inheritance-from-base-trait.tact create mode 100644 src/types/test/override-for-non-existing-function-in-trait-with-multi-inheritance.tact create mode 100644 src/types/test/override-for-non-existing-function-in-trait-without-inheritance.tact create mode 100644 src/types/test/override-for-non-existing-function-in-trait.tact diff --git a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap index adcfecf6e..1cfb62f71 100644 --- a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap +++ b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap @@ -433,6 +433,86 @@ Line 9, col 1: " `; +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-contract 1`] = ` +":5:5: Function "foo" overrides nothing, remove "override" modifier +Line 5, col 5: + 4 | trait Test with T { +> 5 | override fun foo() {} + ^~~~~~~~~~~~~~~~~~~~~ + 6 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-contract-from-base-trait 1`] = ` +":6:5: Function "foo" overrides nothing, remove "override" modifier or inherit any traits with this function +Line 6, col 5: + 5 | trait Test { +> 6 | override fun foo() {} + ^~~~~~~~~~~~~~~~~~~~~ + 7 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-contract-with-multi-inheritance 1`] = ` +":11:5: Function "foo" overrides nothing, remove "override" modifier +Line 11, col 5: + 10 | contract Test with T, T2 { +> 11 | override fun foo() {} + ^~~~~~~~~~~~~~~~~~~~~ + 12 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-contract-without-inheritance 1`] = ` +":4:5: Function "foo" overrides nothing, remove "override" modifier or inherit any traits with this function +Line 4, col 5: + 3 | trait Test { +> 4 | override fun foo() {} + ^~~~~~~~~~~~~~~~~~~~~ + 5 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-trait 1`] = ` +":5:5: Function "foo" overrides nothing, remove "override" modifier +Line 5, col 5: + 4 | contract Test with T { +> 5 | override fun foo() {} + ^~~~~~~~~~~~~~~~~~~~~ + 6 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-trait-from-base-trait 1`] = ` +":6:5: Function "foo" overrides nothing, remove "override" modifier or inherit any traits with this function +Line 6, col 5: + 5 | contract Test { +> 6 | override fun foo() {} + ^~~~~~~~~~~~~~~~~~~~~ + 7 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-trait-with-multi-inheritance 1`] = ` +":11:5: Function "foo" overrides nothing, remove "override" modifier +Line 11, col 5: + 10 | trait Test with T, T2 { +> 11 | override fun foo() {} + ^~~~~~~~~~~~~~~~~~~~~ + 12 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-trait-without-inheritance 1`] = ` +":4:5: Function "foo" overrides nothing, remove "override" modifier or inherit any traits with this function +Line 4, col 5: + 3 | contract Test { +> 4 | override fun foo() {} + ^~~~~~~~~~~~~~~~~~~~~ + 5 | } +" +`; + exports[`resolveDescriptors should fail descriptors for scope-contract-shadows-contract 1`] = ` ":12:1: Type "Main" already exists Line 12, col 1: @@ -12303,6 +12383,5251 @@ exports[`resolveDescriptors should resolve descriptors for message-opcode-expr 1 exports[`resolveDescriptors should resolve descriptors for message-opcode-expr 2`] = `[]`; +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract 1`] = ` +[ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T { + fun foo() {} +}, + "name": { + "id": 3, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 10, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 9, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 11, + "kind": "trait", + "loc": trait Test with T { + override fun foo() {} +}, + "name": { + "id": 7, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 8, + "kind": "id", + "loc": T, + "text": "T", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 10, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 9, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": true, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T { + fun foo() {} +}, + "name": { + "id": 3, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract-from-base-trait 1`] = ` +[ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 7, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 6, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 8, + "kind": "trait", + "loc": trait Test { + override fun foo() {} +}, + "name": { + "id": 5, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 7, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 6, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": true, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract-from-base-trait 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract-with-multi-inheritance 1`] = ` +[ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait T {}, + "name": { + "id": 3, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 7, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 6, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 8, + "kind": "trait", + "loc": trait T2 { + fun foo() {} +}, + "name": { + "id": 5, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 7, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 6, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 13, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 12, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 14, + "kind": "contract", + "loc": contract Test with T, T2 { + override fun foo() {} +}, + "name": { + "id": 9, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 10, + "kind": "id", + "loc": T, + "text": "T", + }, + { + "id": 11, + "kind": "id", + "loc": T2, + "text": "T2", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 13, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 12, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": true, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + }, + "header": null, + "init": { + "ast": { + "id": 16, + "kind": "contract_init", + "loc": contract Test with T, T2 { + override fun foo() {} +}, + "params": [], + "statements": [], + }, + "params": [], + }, + "interfaces": [], + "kind": "contract", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait T {}, + "name": { + "id": 3, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 7, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 6, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 8, + "kind": "trait", + "loc": trait T2 { + fun foo() {} +}, + "name": { + "id": 5, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 7, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 6, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 54378, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract-with-multi-inheritance 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract-with-multi-inheritance-from-base-trait 1`] = ` +[ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 7, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 6, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 8, + "kind": "trait", + "loc": trait T { + fun bar() {} +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "bar" => { + "ast": { + "attributes": [], + "id": 7, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 6, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + "foo" => { + "ast": { + "attributes": [], + "id": 23, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 11, + "kind": "function_def", + "loc": fun baz() {}, + "name": { + "id": 10, + "kind": "id", + "loc": baz, + "text": "baz", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 12, + "kind": "trait", + "loc": trait T2 { + fun baz() {} +}, + "name": { + "id": 9, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "baz" => { + "ast": { + "attributes": [], + "id": 11, + "kind": "function_def", + "loc": fun baz() {}, + "name": { + "id": 10, + "kind": "id", + "loc": baz, + "text": "baz", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "baz", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + "foo" => { + "ast": { + "attributes": [], + "id": 24, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 17, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 16, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 18, + "kind": "contract", + "loc": contract Test with T, T2 { + override fun foo() {} +}, + "name": { + "id": 13, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 14, + "kind": "id", + "loc": T, + "text": "T", + }, + { + "id": 15, + "kind": "id", + "loc": T2, + "text": "T2", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 17, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 16, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": true, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + "bar" => { + "ast": { + "attributes": [], + "id": 21, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 6, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + "baz" => { + "ast": { + "attributes": [], + "id": 22, + "kind": "function_def", + "loc": fun baz() {}, + "name": { + "id": 10, + "kind": "id", + "loc": baz, + "text": "baz", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "baz", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + }, + "header": null, + "init": { + "ast": { + "id": 20, + "kind": "contract_init", + "loc": contract Test with T, T2 { + override fun foo() {} +}, + "params": [], + "statements": [], + }, + "params": [], + }, + "interfaces": [], + "kind": "contract", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 7, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 6, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 8, + "kind": "trait", + "loc": trait T { + fun bar() {} +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "bar" => { + "ast": { + "attributes": [], + "id": 7, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 6, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + "foo" => { + "ast": { + "attributes": [], + "id": 23, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 11, + "kind": "function_def", + "loc": fun baz() {}, + "name": { + "id": 10, + "kind": "id", + "loc": baz, + "text": "baz", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 12, + "kind": "trait", + "loc": trait T2 { + fun baz() {} +}, + "name": { + "id": 9, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "baz" => { + "ast": { + "attributes": [], + "id": 11, + "kind": "function_def", + "loc": fun baz() {}, + "name": { + "id": 10, + "kind": "id", + "loc": baz, + "text": "baz", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "baz", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + "foo" => { + "ast": { + "attributes": [], + "id": 24, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 54378, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract-with-multi-inheritance-from-base-trait 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract-without-inheritance 1`] = ` +[ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait Test { + fun foo() {} +}, + "name": { + "id": 3, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract-without-inheritance 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait 1`] = ` +[ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T { + fun foo() {} +}, + "name": { + "id": 3, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 10, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 9, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 11, + "kind": "contract", + "loc": contract Test with T { + override fun foo() {} +}, + "name": { + "id": 7, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 8, + "kind": "id", + "loc": T, + "text": "T", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 10, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 9, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": true, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + }, + "header": null, + "init": { + "ast": { + "id": 13, + "kind": "contract_init", + "loc": contract Test with T { + override fun foo() {} +}, + "params": [], + "statements": [], + }, + "params": [], + }, + "interfaces": [], + "kind": "contract", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T { + fun foo() {} +}, + "name": { + "id": 3, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait-from-base-trait 1`] = ` +[ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 7, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 6, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 8, + "kind": "contract", + "loc": contract Test { + override fun foo() {} +}, + "name": { + "id": 5, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 7, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 6, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": true, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + }, + "header": null, + "init": { + "ast": { + "id": 10, + "kind": "contract_init", + "loc": contract Test { + override fun foo() {} +}, + "params": [], + "statements": [], + }, + "params": [], + }, + "interfaces": [], + "kind": "contract", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait-from-base-trait 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait-with-multi-inheritance 1`] = ` +[ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait T {}, + "name": { + "id": 3, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 7, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 6, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 8, + "kind": "trait", + "loc": trait T2 { + fun foo() {} +}, + "name": { + "id": 5, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 7, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 6, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 13, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 12, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 14, + "kind": "trait", + "loc": trait Test with T, T2 { + override fun foo() {} +}, + "name": { + "id": 9, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 10, + "kind": "id", + "loc": T, + "text": "T", + }, + { + "id": 11, + "kind": "id", + "loc": T2, + "text": "T2", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 13, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 12, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": true, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait T {}, + "name": { + "id": 3, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 7, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 6, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 8, + "kind": "trait", + "loc": trait T2 { + fun foo() {} +}, + "name": { + "id": 5, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 7, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 6, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 54378, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait-with-multi-inheritance 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait-with-multi-inheritance-from-base-trait 1`] = ` +[ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 7, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 6, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 8, + "kind": "trait", + "loc": trait T { + fun bar() {} +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "bar" => { + "ast": { + "attributes": [], + "id": 7, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 6, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + "foo" => { + "ast": { + "attributes": [], + "id": 22, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 11, + "kind": "function_def", + "loc": fun baz() {}, + "name": { + "id": 10, + "kind": "id", + "loc": baz, + "text": "baz", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 12, + "kind": "trait", + "loc": trait T2 { + fun baz() {} +}, + "name": { + "id": 9, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "baz" => { + "ast": { + "attributes": [], + "id": 11, + "kind": "function_def", + "loc": fun baz() {}, + "name": { + "id": 10, + "kind": "id", + "loc": baz, + "text": "baz", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "baz", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + "foo" => { + "ast": { + "attributes": [], + "id": 23, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 17, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 16, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 18, + "kind": "trait", + "loc": trait Test with T, T2 { + override fun foo() {} +}, + "name": { + "id": 13, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 14, + "kind": "id", + "loc": T, + "text": "T", + }, + { + "id": 15, + "kind": "id", + "loc": T2, + "text": "T2", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 17, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 16, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": true, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + "bar" => { + "ast": { + "attributes": [], + "id": 20, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 6, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + "baz" => { + "ast": { + "attributes": [], + "id": 21, + "kind": "function_def", + "loc": fun baz() {}, + "name": { + "id": 10, + "kind": "id", + "loc": baz, + "text": "baz", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "baz", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 7, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 6, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 8, + "kind": "trait", + "loc": trait T { + fun bar() {} +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "bar" => { + "ast": { + "attributes": [], + "id": 7, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 6, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + "foo" => { + "ast": { + "attributes": [], + "id": 22, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 11, + "kind": "function_def", + "loc": fun baz() {}, + "name": { + "id": 10, + "kind": "id", + "loc": baz, + "text": "baz", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 12, + "kind": "trait", + "loc": trait T2 { + fun baz() {} +}, + "name": { + "id": 9, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "baz" => { + "ast": { + "attributes": [], + "id": 11, + "kind": "function_def", + "loc": fun baz() {}, + "name": { + "id": 10, + "kind": "id", + "loc": baz, + "text": "baz", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "baz", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + "foo" => { + "ast": { + "attributes": [], + "id": 23, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 54378, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait-with-multi-inheritance-from-base-trait 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait-without-inheritance 1`] = ` +[ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "contract", + "loc": contract Test { + fun foo() {} +}, + "name": { + "id": 3, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + }, + "header": null, + "init": { + "ast": { + "id": 8, + "kind": "contract_init", + "loc": contract Test { + fun foo() {} +}, + "params": [], + "statements": [], + }, + "params": [], + }, + "interfaces": [], + "kind": "contract", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait-without-inheritance 2`] = `[]`; + exports[`resolveDescriptors should resolve descriptors for scope-loops 1`] = `[]`; exports[`resolveDescriptors should resolve descriptors for scope-loops 2`] = ` diff --git a/src/types/resolveDescriptors.ts b/src/types/resolveDescriptors.ts index bd82e7ade..e03b39049 100644 --- a/src/types/resolveDescriptors.ts +++ b/src/types/resolveDescriptors.ts @@ -1,23 +1,23 @@ import { + AstAsmFunctionDef, + AstConstantDecl, AstConstantDef, - AstFieldDecl, AstContractInit, + AstExpression, + AstFieldDecl, + AstFunctionDecl, + AstFunctionDef, + AstId, + AstMapType, AstNativeFunctionDecl, AstNode, AstType, - idText, - AstId, + AstTypeId, eqNames, - AstFunctionDef, + FactoryAst, + idText, isSelfId, isSlice, - AstFunctionDecl, - AstConstantDecl, - AstExpression, - AstMapType, - AstTypeId, - AstAsmFunctionDef, - FactoryAst, } from "../grammar/ast"; import { traverse } from "../grammar/iterators"; import { @@ -25,14 +25,14 @@ import { throwCompilationError, throwInternalCompilerError, } from "../errors"; -import { CompilerContext, Store, createContextStore } from "../context"; +import { CompilerContext, createContextStore, Store } from "../context"; import { ConstantDescription, FieldDescription, - FunctionParameter, FunctionDescription, - InitParameter, + FunctionParameter, InitDescription, + InitParameter, printTypeRef, ReceiverSelector, receiverSelectorName, @@ -46,9 +46,9 @@ import { crc16 } from "../utils/crc16"; import { isSubsetOf } from "../utils/isSubsetOf"; import { evalConstantExpression } from "../constEval"; import { - resolveABIType, intMapKeyFormats, intMapValFormats, + resolveABIType, } from "./resolveABITypeRef"; import { enabledExternals } from "../config/features"; import { isRuntimeType } from "./isRuntimeType"; @@ -1562,6 +1562,33 @@ export function resolveDescriptors(ctx: CompilerContext, Ast: FactoryAst) { // function copyTraits(contractOrTrait: TypeDescription) { + const inheritOnlyBaseTrait = contractOrTrait.traits.length === 1; + + // Check that "override" functions have a super function + for (const funInContractOrTrait of contractOrTrait.functions.values()) { + if (!funInContractOrTrait.isOverride) { + continue; + } + + const foundOverriddenFunction = contractOrTrait.traits.some( + (inheritedTrait) => { + return ( + inheritedTrait.functions.get( + funInContractOrTrait.name, + ) !== undefined + ); + }, + ); + + if (!foundOverriddenFunction) { + const msg = inheritOnlyBaseTrait + ? `Function "${funInContractOrTrait.name}" overrides nothing, remove "override" modifier or inherit any traits with this function` + : `Function "${funInContractOrTrait.name}" overrides nothing, remove "override" modifier`; + + throwCompilationError(msg, funInContractOrTrait.ast.loc); + } + } + for (const inheritedTrait of contractOrTrait.traits) { // Copy functions for (const traitFunction of inheritedTrait.functions.values()) { diff --git a/src/types/test-failed/override-for-non-existing-function-in-contract-from-base-trait.tact b/src/types/test-failed/override-for-non-existing-function-in-contract-from-base-trait.tact new file mode 100644 index 000000000..e56932df7 --- /dev/null +++ b/src/types/test-failed/override-for-non-existing-function-in-contract-from-base-trait.tact @@ -0,0 +1,7 @@ +trait BaseTrait { + fun bar() {} +} + +trait Test { + override fun foo() {} +} diff --git a/src/types/test-failed/override-for-non-existing-function-in-contract-with-multi-inheritance.tact b/src/types/test-failed/override-for-non-existing-function-in-contract-with-multi-inheritance.tact new file mode 100644 index 000000000..b2ff74a3e --- /dev/null +++ b/src/types/test-failed/override-for-non-existing-function-in-contract-with-multi-inheritance.tact @@ -0,0 +1,12 @@ +trait BaseTrait {} +trait T { + fun bar() {} +} + +trait T2 { + fun baz() {} +} + +contract Test with T, T2 { + override fun foo() {} +} diff --git a/src/types/test-failed/override-for-non-existing-function-in-contract-without-inheritance.tact b/src/types/test-failed/override-for-non-existing-function-in-contract-without-inheritance.tact new file mode 100644 index 000000000..f266b6094 --- /dev/null +++ b/src/types/test-failed/override-for-non-existing-function-in-contract-without-inheritance.tact @@ -0,0 +1,5 @@ +trait BaseTrait {} + +trait Test { + override fun foo() {} +} diff --git a/src/types/test-failed/override-for-non-existing-function-in-contract.tact b/src/types/test-failed/override-for-non-existing-function-in-contract.tact new file mode 100644 index 000000000..86e363029 --- /dev/null +++ b/src/types/test-failed/override-for-non-existing-function-in-contract.tact @@ -0,0 +1,6 @@ +trait BaseTrait {} +trait T {} + +trait Test with T { + override fun foo() {} +} diff --git a/src/types/test-failed/override-for-non-existing-function-in-trait-from-base-trait.tact b/src/types/test-failed/override-for-non-existing-function-in-trait-from-base-trait.tact new file mode 100644 index 000000000..c38be3121 --- /dev/null +++ b/src/types/test-failed/override-for-non-existing-function-in-trait-from-base-trait.tact @@ -0,0 +1,7 @@ +trait BaseTrait { + fun bar() {} +} + +contract Test { + override fun foo() {} +} diff --git a/src/types/test-failed/override-for-non-existing-function-in-trait-with-multi-inheritance.tact b/src/types/test-failed/override-for-non-existing-function-in-trait-with-multi-inheritance.tact new file mode 100644 index 000000000..ee3412eb2 --- /dev/null +++ b/src/types/test-failed/override-for-non-existing-function-in-trait-with-multi-inheritance.tact @@ -0,0 +1,12 @@ +trait BaseTrait {} +trait T { + fun bar() {} +} + +trait T2 { + fun baz() {} +} + +trait Test with T, T2 { + override fun foo() {} +} diff --git a/src/types/test-failed/override-for-non-existing-function-in-trait-without-inheritance.tact b/src/types/test-failed/override-for-non-existing-function-in-trait-without-inheritance.tact new file mode 100644 index 000000000..35a2e2498 --- /dev/null +++ b/src/types/test-failed/override-for-non-existing-function-in-trait-without-inheritance.tact @@ -0,0 +1,5 @@ +trait BaseTrait {} + +contract Test { + override fun foo() {} +} diff --git a/src/types/test-failed/override-for-non-existing-function-in-trait.tact b/src/types/test-failed/override-for-non-existing-function-in-trait.tact new file mode 100644 index 000000000..a7a2dd7ea --- /dev/null +++ b/src/types/test-failed/override-for-non-existing-function-in-trait.tact @@ -0,0 +1,6 @@ +trait BaseTrait {} +trait T {} + +contract Test with T { + override fun foo() {} +} diff --git a/src/types/test/override-for-non-existing-function-in-contract-from-base-trait.tact b/src/types/test/override-for-non-existing-function-in-contract-from-base-trait.tact new file mode 100644 index 000000000..5850b0948 --- /dev/null +++ b/src/types/test/override-for-non-existing-function-in-contract-from-base-trait.tact @@ -0,0 +1,7 @@ +trait BaseTrait { + fun foo() {} +} + +trait Test { + override fun foo() {} +} diff --git a/src/types/test/override-for-non-existing-function-in-contract-with-multi-inheritance-from-base-trait.tact b/src/types/test/override-for-non-existing-function-in-contract-with-multi-inheritance-from-base-trait.tact new file mode 100644 index 000000000..268c1cb0c --- /dev/null +++ b/src/types/test/override-for-non-existing-function-in-contract-with-multi-inheritance-from-base-trait.tact @@ -0,0 +1,14 @@ +trait BaseTrait { + fun foo() {} +} +trait T { + fun bar() {} +} + +trait T2 { + fun baz() {} +} + +contract Test with T, T2 { + override fun foo() {} +} diff --git a/src/types/test/override-for-non-existing-function-in-contract-with-multi-inheritance.tact b/src/types/test/override-for-non-existing-function-in-contract-with-multi-inheritance.tact new file mode 100644 index 000000000..f5445f61a --- /dev/null +++ b/src/types/test/override-for-non-existing-function-in-contract-with-multi-inheritance.tact @@ -0,0 +1,10 @@ +trait BaseTrait {} +trait T {} + +trait T2 { + fun foo() {} +} + +contract Test with T, T2 { + override fun foo() {} +} diff --git a/src/types/test/override-for-non-existing-function-in-contract-without-inheritance.tact b/src/types/test/override-for-non-existing-function-in-contract-without-inheritance.tact new file mode 100644 index 000000000..a73316b28 --- /dev/null +++ b/src/types/test/override-for-non-existing-function-in-contract-without-inheritance.tact @@ -0,0 +1,5 @@ +trait BaseTrait {} + +trait Test { + fun foo() {} +} diff --git a/src/types/test/override-for-non-existing-function-in-contract.tact b/src/types/test/override-for-non-existing-function-in-contract.tact new file mode 100644 index 000000000..6ac703839 --- /dev/null +++ b/src/types/test/override-for-non-existing-function-in-contract.tact @@ -0,0 +1,8 @@ +trait BaseTrait {} +trait T { + fun foo() {} +} + +trait Test with T { + override fun foo() {} +} diff --git a/src/types/test/override-for-non-existing-function-in-trait-from-base-trait.tact b/src/types/test/override-for-non-existing-function-in-trait-from-base-trait.tact new file mode 100644 index 000000000..a07d554f8 --- /dev/null +++ b/src/types/test/override-for-non-existing-function-in-trait-from-base-trait.tact @@ -0,0 +1,7 @@ +trait BaseTrait { + fun foo() {} +} + +contract Test { + override fun foo() {} +} diff --git a/src/types/test/override-for-non-existing-function-in-trait-with-multi-inheritance-from-base-trait.tact b/src/types/test/override-for-non-existing-function-in-trait-with-multi-inheritance-from-base-trait.tact new file mode 100644 index 000000000..41091c08a --- /dev/null +++ b/src/types/test/override-for-non-existing-function-in-trait-with-multi-inheritance-from-base-trait.tact @@ -0,0 +1,14 @@ +trait BaseTrait { + fun foo() {} +} +trait T { + fun bar() {} +} + +trait T2 { + fun baz() {} +} + +trait Test with T, T2 { + override fun foo() {} +} diff --git a/src/types/test/override-for-non-existing-function-in-trait-with-multi-inheritance.tact b/src/types/test/override-for-non-existing-function-in-trait-with-multi-inheritance.tact new file mode 100644 index 000000000..37ad7a6f7 --- /dev/null +++ b/src/types/test/override-for-non-existing-function-in-trait-with-multi-inheritance.tact @@ -0,0 +1,10 @@ +trait BaseTrait {} +trait T {} + +trait T2 { + fun foo() {} +} + +trait Test with T, T2 { + override fun foo() {} +} diff --git a/src/types/test/override-for-non-existing-function-in-trait-without-inheritance.tact b/src/types/test/override-for-non-existing-function-in-trait-without-inheritance.tact new file mode 100644 index 000000000..2455dff20 --- /dev/null +++ b/src/types/test/override-for-non-existing-function-in-trait-without-inheritance.tact @@ -0,0 +1,5 @@ +trait BaseTrait {} + +contract Test { + fun foo() {} +} diff --git a/src/types/test/override-for-non-existing-function-in-trait.tact b/src/types/test/override-for-non-existing-function-in-trait.tact new file mode 100644 index 000000000..8ecc75988 --- /dev/null +++ b/src/types/test/override-for-non-existing-function-in-trait.tact @@ -0,0 +1,8 @@ +trait BaseTrait {} +trait T { + fun foo() {} +} + +contract Test with T { + override fun foo() {} +} From 3d6ebef63a5e6760c9b0c307bd746847537aa13c Mon Sep 17 00:00:00 2001 From: i582 <51853996+i582@users.noreply.github.com> Date: Tue, 14 Jan 2025 01:19:31 +0400 Subject: [PATCH 02/11] added missed (?) inheritance --- ...t-vars-analysis-used-uninit-storage-override-fun-call.tact | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/stmts-failed/init-vars-analysis-used-uninit-storage-override-fun-call.tact b/src/types/stmts-failed/init-vars-analysis-used-uninit-storage-override-fun-call.tact index bb15ba90b..0c826fa1d 100644 --- a/src/types/stmts-failed/init-vars-analysis-used-uninit-storage-override-fun-call.tact +++ b/src/types/stmts-failed/init-vars-analysis-used-uninit-storage-override-fun-call.tact @@ -9,7 +9,7 @@ trait AbstractTrait { abstract fun execute(): Int; } -contract Contract { +contract Contract with AbstractTrait { value: Int; init(arg: Bool) { self.execute(); @@ -20,4 +20,4 @@ contract Contract { self.value = self.value + 1; return self.value; } -} \ No newline at end of file +} From 5268abe746a68832a20e8d60012c6e4c3ba52e3f Mon Sep 17 00:00:00 2001 From: i582 <51853996+i582@users.noreply.github.com> Date: Tue, 14 Jan 2025 01:57:28 +0400 Subject: [PATCH 03/11] add CHANGELOG.md entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eaf53e5e6..3082fd3a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The `VarInt16`, `VarInt32`, `VarUint16`, `VarUint32` integer serialization types: PR [#1186](https://github.com/tact-lang/tact/pull/1186) - `unboc`: a standalone CLI utility to expose Tact's TVM disassembler: PR [#1259](https://github.com/tact-lang/tact/pull/1259) - Added alternative parser: PR [#1258](https://github.com/tact-lang/tact/pull/1258) +- Check if overridden functions have super function: PR [#1302](https://github.com/tact-lang/tact/pull/1302) ### Changed From 022865adb565ca42a1004a95a48928448220b133 Mon Sep 17 00:00:00 2001 From: i582 <51853996+i582@users.noreply.github.com> Date: Tue, 14 Jan 2025 10:44:23 +0400 Subject: [PATCH 04/11] fixed test files names --- .../resolveDescriptors.spec.ts.snap | 52 +++++++++---------- ...-function-in-contract-from-base-trait.tact | 2 +- ...unction-in-contract-with-inheritance.tact} | 0 ...ction-in-contract-without-inheritance.tact | 2 +- ...-function-in-trait-from-base-trait-2.tact} | 2 +- ...g-function-in-trait-with-inheritance.tact} | 0 ...ction-in-trait-without-inheritance-2.tact} | 2 +- 7 files changed, 30 insertions(+), 30 deletions(-) rename src/types/test-failed/{override-for-non-existing-function-in-trait.tact => override-for-non-existing-function-in-contract-with-inheritance.tact} (100%) rename src/types/test-failed/{override-for-non-existing-function-in-trait-from-base-trait.tact => override-for-non-existing-function-in-trait-from-base-trait-2.tact} (80%) rename src/types/test-failed/{override-for-non-existing-function-in-contract.tact => override-for-non-existing-function-in-trait-with-inheritance.tact} (100%) rename src/types/test-failed/{override-for-non-existing-function-in-trait-without-inheritance.tact => override-for-non-existing-function-in-trait-without-inheritance-2.tact} (75%) diff --git a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap index eadda2cf9..cc7efe3b1 100644 --- a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap +++ b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap @@ -443,26 +443,26 @@ Line 9, col 1: " `; -exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-contract 1`] = ` -":5:5: Function "foo" overrides nothing, remove "override" modifier -Line 5, col 5: - 4 | trait Test with T { -> 5 | override fun foo() {} - ^~~~~~~~~~~~~~~~~~~~~ - 6 | } -" -`; - exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-contract-from-base-trait 1`] = ` ":6:5: Function "foo" overrides nothing, remove "override" modifier or inherit any traits with this function Line 6, col 5: - 5 | trait Test { + 5 | contract Test { > 6 | override fun foo() {} ^~~~~~~~~~~~~~~~~~~~~ 7 | } " `; +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-contract-with-inheritance 1`] = ` +":5:5: Function "foo" overrides nothing, remove "override" modifier +Line 5, col 5: + 4 | contract Test with T { +> 5 | override fun foo() {} + ^~~~~~~~~~~~~~~~~~~~~ + 6 | } +" +`; + exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-contract-with-multi-inheritance 1`] = ` ":11:5: Function "foo" overrides nothing, remove "override" modifier Line 11, col 5: @@ -476,33 +476,33 @@ Line 11, col 5: exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-contract-without-inheritance 1`] = ` ":4:5: Function "foo" overrides nothing, remove "override" modifier or inherit any traits with this function Line 4, col 5: - 3 | trait Test { + 3 | contract Test { > 4 | override fun foo() {} ^~~~~~~~~~~~~~~~~~~~~ 5 | } " `; -exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-trait 1`] = ` -":5:5: Function "foo" overrides nothing, remove "override" modifier -Line 5, col 5: - 4 | contract Test with T { -> 5 | override fun foo() {} - ^~~~~~~~~~~~~~~~~~~~~ - 6 | } -" -`; - -exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-trait-from-base-trait 1`] = ` +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-trait-from-base-trait-2 1`] = ` ":6:5: Function "foo" overrides nothing, remove "override" modifier or inherit any traits with this function Line 6, col 5: - 5 | contract Test { + 5 | trait Test { > 6 | override fun foo() {} ^~~~~~~~~~~~~~~~~~~~~ 7 | } " `; +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-trait-with-inheritance 1`] = ` +":5:5: Function "foo" overrides nothing, remove "override" modifier +Line 5, col 5: + 4 | trait Test with T { +> 5 | override fun foo() {} + ^~~~~~~~~~~~~~~~~~~~~ + 6 | } +" +`; + exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-trait-with-multi-inheritance 1`] = ` ":11:5: Function "foo" overrides nothing, remove "override" modifier Line 11, col 5: @@ -513,10 +513,10 @@ Line 11, col 5: " `; -exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-trait-without-inheritance 1`] = ` +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-trait-without-inheritance-2 1`] = ` ":4:5: Function "foo" overrides nothing, remove "override" modifier or inherit any traits with this function Line 4, col 5: - 3 | contract Test { + 3 | trait Test { > 4 | override fun foo() {} ^~~~~~~~~~~~~~~~~~~~~ 5 | } diff --git a/src/types/test-failed/override-for-non-existing-function-in-contract-from-base-trait.tact b/src/types/test-failed/override-for-non-existing-function-in-contract-from-base-trait.tact index e56932df7..c38be3121 100644 --- a/src/types/test-failed/override-for-non-existing-function-in-contract-from-base-trait.tact +++ b/src/types/test-failed/override-for-non-existing-function-in-contract-from-base-trait.tact @@ -2,6 +2,6 @@ trait BaseTrait { fun bar() {} } -trait Test { +contract Test { override fun foo() {} } diff --git a/src/types/test-failed/override-for-non-existing-function-in-trait.tact b/src/types/test-failed/override-for-non-existing-function-in-contract-with-inheritance.tact similarity index 100% rename from src/types/test-failed/override-for-non-existing-function-in-trait.tact rename to src/types/test-failed/override-for-non-existing-function-in-contract-with-inheritance.tact diff --git a/src/types/test-failed/override-for-non-existing-function-in-contract-without-inheritance.tact b/src/types/test-failed/override-for-non-existing-function-in-contract-without-inheritance.tact index f266b6094..35a2e2498 100644 --- a/src/types/test-failed/override-for-non-existing-function-in-contract-without-inheritance.tact +++ b/src/types/test-failed/override-for-non-existing-function-in-contract-without-inheritance.tact @@ -1,5 +1,5 @@ trait BaseTrait {} -trait Test { +contract Test { override fun foo() {} } diff --git a/src/types/test-failed/override-for-non-existing-function-in-trait-from-base-trait.tact b/src/types/test-failed/override-for-non-existing-function-in-trait-from-base-trait-2.tact similarity index 80% rename from src/types/test-failed/override-for-non-existing-function-in-trait-from-base-trait.tact rename to src/types/test-failed/override-for-non-existing-function-in-trait-from-base-trait-2.tact index c38be3121..e56932df7 100644 --- a/src/types/test-failed/override-for-non-existing-function-in-trait-from-base-trait.tact +++ b/src/types/test-failed/override-for-non-existing-function-in-trait-from-base-trait-2.tact @@ -2,6 +2,6 @@ trait BaseTrait { fun bar() {} } -contract Test { +trait Test { override fun foo() {} } diff --git a/src/types/test-failed/override-for-non-existing-function-in-contract.tact b/src/types/test-failed/override-for-non-existing-function-in-trait-with-inheritance.tact similarity index 100% rename from src/types/test-failed/override-for-non-existing-function-in-contract.tact rename to src/types/test-failed/override-for-non-existing-function-in-trait-with-inheritance.tact diff --git a/src/types/test-failed/override-for-non-existing-function-in-trait-without-inheritance.tact b/src/types/test-failed/override-for-non-existing-function-in-trait-without-inheritance-2.tact similarity index 75% rename from src/types/test-failed/override-for-non-existing-function-in-trait-without-inheritance.tact rename to src/types/test-failed/override-for-non-existing-function-in-trait-without-inheritance-2.tact index 35a2e2498..f266b6094 100644 --- a/src/types/test-failed/override-for-non-existing-function-in-trait-without-inheritance.tact +++ b/src/types/test-failed/override-for-non-existing-function-in-trait-without-inheritance-2.tact @@ -1,5 +1,5 @@ trait BaseTrait {} -contract Test { +trait Test { override fun foo() {} } From 6b3b5515063ae0f861dd0529cddfc591096a5414 Mon Sep 17 00:00:00 2001 From: i582 <51853996+i582@users.noreply.github.com> Date: Tue, 14 Jan 2025 10:49:05 +0400 Subject: [PATCH 05/11] removed tests without override --- ...on-existing-function-in-contract-without-inheritance.tact | 5 ----- ...r-non-existing-function-in-trait-without-inheritance.tact | 5 ----- 2 files changed, 10 deletions(-) delete mode 100644 src/types/test/override-for-non-existing-function-in-contract-without-inheritance.tact delete mode 100644 src/types/test/override-for-non-existing-function-in-trait-without-inheritance.tact diff --git a/src/types/test/override-for-non-existing-function-in-contract-without-inheritance.tact b/src/types/test/override-for-non-existing-function-in-contract-without-inheritance.tact deleted file mode 100644 index a73316b28..000000000 --- a/src/types/test/override-for-non-existing-function-in-contract-without-inheritance.tact +++ /dev/null @@ -1,5 +0,0 @@ -trait BaseTrait {} - -trait Test { - fun foo() {} -} diff --git a/src/types/test/override-for-non-existing-function-in-trait-without-inheritance.tact b/src/types/test/override-for-non-existing-function-in-trait-without-inheritance.tact deleted file mode 100644 index 2455dff20..000000000 --- a/src/types/test/override-for-non-existing-function-in-trait-without-inheritance.tact +++ /dev/null @@ -1,5 +0,0 @@ -trait BaseTrait {} - -contract Test { - fun foo() {} -} From 2d71ef48c54d467bcf15ea696297aba6a34a5e2f Mon Sep 17 00:00:00 2001 From: i582 <51853996+i582@users.noreply.github.com> Date: Tue, 14 Jan 2025 10:52:34 +0400 Subject: [PATCH 06/11] renamed positive tests --- ...erride-for-existing-function-in-contract-from-base-trait.tact} | 0 ...ction-in-contract-with-multi-inheritance-from-base-trait.tact} | 0 ...for-existing-function-in-contract-with-multi-inheritance.tact} | 0 ...tract.tact => override-for-existing-function-in-contract.tact} | 0 ... override-for-existing-function-in-trait-from-base-trait.tact} | 0 ...function-in-trait-with-multi-inheritance-from-base-trait.tact} | 0 ...de-for-existing-function-in-trait-with-multi-inheritance.tact} | 0 ...in-trait.tact => override-for-existing-function-in-trait.tact} | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename src/types/test/{override-for-non-existing-function-in-contract-from-base-trait.tact => override-for-existing-function-in-contract-from-base-trait.tact} (100%) rename src/types/test/{override-for-non-existing-function-in-contract-with-multi-inheritance-from-base-trait.tact => override-for-existing-function-in-contract-with-multi-inheritance-from-base-trait.tact} (100%) rename src/types/test/{override-for-non-existing-function-in-contract-with-multi-inheritance.tact => override-for-existing-function-in-contract-with-multi-inheritance.tact} (100%) rename src/types/test/{override-for-non-existing-function-in-contract.tact => override-for-existing-function-in-contract.tact} (100%) rename src/types/test/{override-for-non-existing-function-in-trait-from-base-trait.tact => override-for-existing-function-in-trait-from-base-trait.tact} (100%) rename src/types/test/{override-for-non-existing-function-in-trait-with-multi-inheritance-from-base-trait.tact => override-for-existing-function-in-trait-with-multi-inheritance-from-base-trait.tact} (100%) rename src/types/test/{override-for-non-existing-function-in-trait-with-multi-inheritance.tact => override-for-existing-function-in-trait-with-multi-inheritance.tact} (100%) rename src/types/test/{override-for-non-existing-function-in-trait.tact => override-for-existing-function-in-trait.tact} (100%) diff --git a/src/types/test/override-for-non-existing-function-in-contract-from-base-trait.tact b/src/types/test/override-for-existing-function-in-contract-from-base-trait.tact similarity index 100% rename from src/types/test/override-for-non-existing-function-in-contract-from-base-trait.tact rename to src/types/test/override-for-existing-function-in-contract-from-base-trait.tact diff --git a/src/types/test/override-for-non-existing-function-in-contract-with-multi-inheritance-from-base-trait.tact b/src/types/test/override-for-existing-function-in-contract-with-multi-inheritance-from-base-trait.tact similarity index 100% rename from src/types/test/override-for-non-existing-function-in-contract-with-multi-inheritance-from-base-trait.tact rename to src/types/test/override-for-existing-function-in-contract-with-multi-inheritance-from-base-trait.tact diff --git a/src/types/test/override-for-non-existing-function-in-contract-with-multi-inheritance.tact b/src/types/test/override-for-existing-function-in-contract-with-multi-inheritance.tact similarity index 100% rename from src/types/test/override-for-non-existing-function-in-contract-with-multi-inheritance.tact rename to src/types/test/override-for-existing-function-in-contract-with-multi-inheritance.tact diff --git a/src/types/test/override-for-non-existing-function-in-contract.tact b/src/types/test/override-for-existing-function-in-contract.tact similarity index 100% rename from src/types/test/override-for-non-existing-function-in-contract.tact rename to src/types/test/override-for-existing-function-in-contract.tact diff --git a/src/types/test/override-for-non-existing-function-in-trait-from-base-trait.tact b/src/types/test/override-for-existing-function-in-trait-from-base-trait.tact similarity index 100% rename from src/types/test/override-for-non-existing-function-in-trait-from-base-trait.tact rename to src/types/test/override-for-existing-function-in-trait-from-base-trait.tact diff --git a/src/types/test/override-for-non-existing-function-in-trait-with-multi-inheritance-from-base-trait.tact b/src/types/test/override-for-existing-function-in-trait-with-multi-inheritance-from-base-trait.tact similarity index 100% rename from src/types/test/override-for-non-existing-function-in-trait-with-multi-inheritance-from-base-trait.tact rename to src/types/test/override-for-existing-function-in-trait-with-multi-inheritance-from-base-trait.tact diff --git a/src/types/test/override-for-non-existing-function-in-trait-with-multi-inheritance.tact b/src/types/test/override-for-existing-function-in-trait-with-multi-inheritance.tact similarity index 100% rename from src/types/test/override-for-non-existing-function-in-trait-with-multi-inheritance.tact rename to src/types/test/override-for-existing-function-in-trait-with-multi-inheritance.tact diff --git a/src/types/test/override-for-non-existing-function-in-trait.tact b/src/types/test/override-for-existing-function-in-trait.tact similarity index 100% rename from src/types/test/override-for-non-existing-function-in-trait.tact rename to src/types/test/override-for-existing-function-in-trait.tact From 50b146609b4e5086fe6b0180c29ee19c6709a8ec Mon Sep 17 00:00:00 2001 From: i582 <51853996+i582@users.noreply.github.com> Date: Tue, 14 Jan 2025 10:55:25 +0400 Subject: [PATCH 07/11] moved and reworded CHANGELOG.md entry to Fixed --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3082fd3a8..8f0d13746 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The `VarInt16`, `VarInt32`, `VarUint16`, `VarUint32` integer serialization types: PR [#1186](https://github.com/tact-lang/tact/pull/1186) - `unboc`: a standalone CLI utility to expose Tact's TVM disassembler: PR [#1259](https://github.com/tact-lang/tact/pull/1259) - Added alternative parser: PR [#1258](https://github.com/tact-lang/tact/pull/1258) -- Check if overridden functions have super function: PR [#1302](https://github.com/tact-lang/tact/pull/1302) ### Changed @@ -47,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The typechecker now rejects integer map key types with variable width (`coins`, `varint16`, `varint32`, `varuint16`, `varuint32`): PR [#1276](https://github.com/tact-lang/tact/pull/1276) - Code generation for `self` argument in optional struct methods: PR [#1284](https://github.com/tact-lang/tact/pull/1284) - 'The "remainder" field can only be the last field:' inspection now shows location: PR [#1300](https://github.com/tact-lang/tact/pull/1300) +- Forbid override modifier for functions without super function: PR [#1302](https://github.com/tact-lang/tact/pull/1302) ### Docs From 1bb334b234ff41b94edc2064dfa3649270bc1a9d Mon Sep 17 00:00:00 2001 From: i582 <51853996+i582@users.noreply.github.com> Date: Tue, 14 Jan 2025 10:59:23 +0400 Subject: [PATCH 08/11] update tests snapshot, add test for deep inheritance --- .../resolveDescriptors.spec.ts.snap | 2183 ++++++++++++++--- ...nction-in-trait-with-deep-inheritance.tact | 11 + 2 files changed, 1825 insertions(+), 369 deletions(-) create mode 100644 src/types/test/override-for-existing-function-in-trait-with-deep-inheritance.tact diff --git a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap index cc7efe3b1..6b0bfa641 100644 --- a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap +++ b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap @@ -12728,7 +12728,7 @@ exports[`resolveDescriptors should resolve descriptors for message-opcode-expr 1 exports[`resolveDescriptors should resolve descriptors for message-opcode-expr 2`] = `[]`; -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract 1`] = ` +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-contract 1`] = ` [ { "ast": { @@ -13141,9 +13141,9 @@ exports[`resolveDescriptors should resolve descriptors for override-for-non-exis ] `; -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract 2`] = `[]`; +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-contract 2`] = `[]`; -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract-from-base-trait 1`] = ` +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-contract-from-base-trait 1`] = ` [ { "ast": { @@ -13419,9 +13419,9 @@ exports[`resolveDescriptors should resolve descriptors for override-for-non-exis ] `; -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract-from-base-trait 2`] = `[]`; +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-contract-from-base-trait 2`] = `[]`; -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract-with-multi-inheritance 1`] = ` +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-contract-with-multi-inheritance 1`] = ` [ { "ast": { @@ -13981,9 +13981,9 @@ exports[`resolveDescriptors should resolve descriptors for override-for-non-exis ] `; -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract-with-multi-inheritance 2`] = `[]`; +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-contract-with-multi-inheritance 2`] = `[]`; -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract-with-multi-inheritance-from-base-trait 1`] = ` +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-contract-with-multi-inheritance-from-base-trait 1`] = ` [ { "ast": { @@ -15185,167 +15185,9 @@ exports[`resolveDescriptors should resolve descriptors for override-for-non-exis ] `; -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract-with-multi-inheritance-from-base-trait 2`] = `[]`; +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-contract-with-multi-inheritance-from-base-trait 2`] = `[]`; -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract-without-inheritance 1`] = ` -[ - { - "ast": { - "attributes": [], - "declarations": [], - "id": 2, - "kind": "trait", - "loc": trait BaseTrait {}, - "name": { - "id": 1, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", - }, - "traits": [], - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "trait", - "name": "BaseTrait", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 1020, - }, - { - "ast": { - "attributes": [], - "declarations": [ - { - "attributes": [], - "id": 5, - "kind": "function_def", - "loc": fun foo() {}, - "name": { - "id": 4, - "kind": "id", - "loc": foo, - "text": "foo", - }, - "params": [], - "return": null, - "statements": [], - }, - ], - "id": 6, - "kind": "trait", - "loc": trait Test { - fun foo() {} -}, - "name": { - "id": 3, - "kind": "id", - "loc": Test, - "text": "Test", - }, - "traits": [], - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map { - "foo" => { - "ast": { - "attributes": [], - "id": 5, - "kind": "function_def", - "loc": fun foo() {}, - "name": { - "id": 4, - "kind": "id", - "loc": foo, - "text": "foo", - }, - "params": [], - "return": null, - "statements": [], - }, - "isAbstract": false, - "isGetter": false, - "isInline": false, - "isMutating": true, - "isOverride": false, - "isVirtual": false, - "methodId": null, - "name": "foo", - "origin": "user", - "params": [], - "returns": { - "kind": "void", - }, - "self": { - "kind": "ref", - "name": "Test", - "optional": false, - }, - }, - }, - "header": null, - "init": null, - "interfaces": [], - "kind": "trait", - "name": "Test", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [ - { - "ast": { - "attributes": [], - "declarations": [], - "id": 2, - "kind": "trait", - "loc": trait BaseTrait {}, - "name": { - "id": 1, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", - }, - "traits": [], - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "trait", - "name": "BaseTrait", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 1020, - }, - ], - "uid": 44104, - }, -] -`; - -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-contract-without-inheritance 2`] = `[]`; - -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait 1`] = ` +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait 1`] = ` [ { "ast": { @@ -15769,9 +15611,9 @@ exports[`resolveDescriptors should resolve descriptors for override-for-non-exis ] `; -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait 2`] = `[]`; +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait 2`] = `[]`; -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait-from-base-trait 1`] = ` +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait-from-base-trait 1`] = ` [ { "ast": { @@ -15955,28 +15797,1769 @@ exports[`resolveDescriptors should resolve descriptors for override-for-non-exis "params": [], "statements": [], }, - "params": [], - }, - "interfaces": [], - "kind": "contract", - "name": "Test", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [ + "params": [], + }, + "interfaces": [], + "kind": "contract", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + fun foo() {} +}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 3, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 2, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "BaseTrait", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait-from-base-trait 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait-with-deep-inheritance 1`] = ` +[ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T1 { fun foo() {} }, + "name": { + "id": 3, + "kind": "id", + "loc": T1, + "text": "T1", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T1", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T1", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 58377, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 9, + "kind": "trait", + "loc": trait T2 with T1 {}, + "name": { + "id": 7, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 8, + "kind": "id", + "loc": T1, + "text": "T1", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 21, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T1 { fun foo() {} }, + "name": { + "id": 3, + "kind": "id", + "loc": T1, + "text": "T1", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T1", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T1", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 58377, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 12, + "kind": "trait", + "loc": trait T3 with T2 {}, + "name": { + "id": 10, + "kind": "id", + "loc": T3, + "text": "T3", + }, + "traits": [ + { + "id": 11, + "kind": "id", + "loc": T2, + "text": "T2", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 20, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T3", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T3", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 9, + "kind": "trait", + "loc": trait T2 with T1 {}, + "name": { + "id": 7, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 8, + "kind": "id", + "loc": T1, + "text": "T1", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 21, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T1 { fun foo() {} }, + "name": { + "id": 3, + "kind": "id", + "loc": T1, + "text": "T1", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T1", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T1", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 58377, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T1 { fun foo() {} }, + "name": { + "id": 3, + "kind": "id", + "loc": T1, + "text": "T1", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T1", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T1", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 58377, + }, + ], + "uid": 50251, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 16, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 15, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 17, + "kind": "contract", + "loc": contract Test with T3 { + override fun foo() {} +}, + "name": { + "id": 13, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 14, + "kind": "id", + "loc": T3, + "text": "T3", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 16, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 15, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": true, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + }, + "header": null, + "init": { + "ast": { + "id": 19, + "kind": "contract_init", + "loc": contract Test with T3 { + override fun foo() {} +}, + "params": [], + "statements": [], + }, + "params": [], + }, + "interfaces": [], + "kind": "contract", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 12, + "kind": "trait", + "loc": trait T3 with T2 {}, + "name": { + "id": 10, + "kind": "id", + "loc": T3, + "text": "T3", + }, + "traits": [ + { + "id": 11, + "kind": "id", + "loc": T2, + "text": "T2", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 20, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T3", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T3", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 9, + "kind": "trait", + "loc": trait T2 with T1 {}, + "name": { + "id": 7, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 8, + "kind": "id", + "loc": T1, + "text": "T1", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 21, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T1 { fun foo() {} }, + "name": { + "id": 3, + "kind": "id", + "loc": T1, + "text": "T1", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T1", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T1", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 58377, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T1 { fun foo() {} }, + "name": { + "id": 3, + "kind": "id", + "loc": T1, + "text": "T1", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T1", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T1", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 58377, + }, + ], + "uid": 50251, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 9, + "kind": "trait", + "loc": trait T2 with T1 {}, + "name": { + "id": 7, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 8, + "kind": "id", + "loc": T1, + "text": "T1", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 21, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T1 { fun foo() {} }, + "name": { + "id": 3, + "kind": "id", + "loc": T1, + "text": "T1", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 4, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T1", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T1", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 58377, + }, + ], + "uid": 54378, + }, { "ast": { "attributes": [], "declarations": [ { "attributes": [], - "id": 3, + "id": 5, "kind": "function_def", "loc": fun foo() {}, "name": { - "id": 2, + "id": 4, "kind": "id", "loc": foo, "text": "foo", @@ -15986,16 +17569,14 @@ exports[`resolveDescriptors should resolve descriptors for override-for-non-exis "statements": [], }, ], - "id": 4, + "id": 6, "kind": "trait", - "loc": trait BaseTrait { - fun foo() {} -}, + "loc": trait T1 { fun foo() {} }, "name": { - "id": 1, + "id": 3, "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", + "loc": T1, + "text": "T1", }, "traits": [], }, @@ -16006,11 +17587,11 @@ exports[`resolveDescriptors should resolve descriptors for override-for-non-exis "foo" => { "ast": { "attributes": [], - "id": 3, + "id": 5, "kind": "function_def", "loc": fun foo() {}, "name": { - "id": 2, + "id": 4, "kind": "id", "loc": foo, "text": "foo", @@ -16034,7 +17615,7 @@ exports[`resolveDescriptors should resolve descriptors for override-for-non-exis }, "self": { "kind": "ref", - "name": "BaseTrait", + "name": "T1", "optional": false, }, }, @@ -16043,14 +17624,47 @@ exports[`resolveDescriptors should resolve descriptors for override-for-non-exis "init": null, "interfaces": [], "kind": "trait", - "name": "BaseTrait", + "name": "T1", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, - "traits": [], - "uid": 1020, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 58377, }, ], "uid": 44104, @@ -16058,9 +17672,9 @@ exports[`resolveDescriptors should resolve descriptors for override-for-non-exis ] `; -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait-from-base-trait 2`] = `[]`; +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait-with-deep-inheritance 2`] = `[]`; -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait-with-multi-inheritance 1`] = ` +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait-with-multi-inheritance 1`] = ` [ { "ast": { @@ -16609,9 +18223,9 @@ exports[`resolveDescriptors should resolve descriptors for override-for-non-exis ] `; -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait-with-multi-inheritance 2`] = `[]`; +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait-with-multi-inheritance 2`] = `[]`; -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait-with-multi-inheritance-from-base-trait 1`] = ` +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait-with-multi-inheritance-from-base-trait 1`] = ` [ { "ast": { @@ -17802,176 +19416,7 @@ exports[`resolveDescriptors should resolve descriptors for override-for-non-exis ] `; -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait-with-multi-inheritance-from-base-trait 2`] = `[]`; - -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait-without-inheritance 1`] = ` -[ - { - "ast": { - "attributes": [], - "declarations": [], - "id": 2, - "kind": "trait", - "loc": trait BaseTrait {}, - "name": { - "id": 1, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", - }, - "traits": [], - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "trait", - "name": "BaseTrait", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 1020, - }, - { - "ast": { - "attributes": [], - "declarations": [ - { - "attributes": [], - "id": 5, - "kind": "function_def", - "loc": fun foo() {}, - "name": { - "id": 4, - "kind": "id", - "loc": foo, - "text": "foo", - }, - "params": [], - "return": null, - "statements": [], - }, - ], - "id": 6, - "kind": "contract", - "loc": contract Test { - fun foo() {} -}, - "name": { - "id": 3, - "kind": "id", - "loc": Test, - "text": "Test", - }, - "traits": [], - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map { - "foo" => { - "ast": { - "attributes": [], - "id": 5, - "kind": "function_def", - "loc": fun foo() {}, - "name": { - "id": 4, - "kind": "id", - "loc": foo, - "text": "foo", - }, - "params": [], - "return": null, - "statements": [], - }, - "isAbstract": false, - "isGetter": false, - "isInline": false, - "isMutating": true, - "isOverride": false, - "isVirtual": false, - "methodId": null, - "name": "foo", - "origin": "user", - "params": [], - "returns": { - "kind": "void", - }, - "self": { - "kind": "ref", - "name": "Test", - "optional": false, - }, - }, - }, - "header": null, - "init": { - "ast": { - "id": 8, - "kind": "contract_init", - "loc": contract Test { - fun foo() {} -}, - "params": [], - "statements": [], - }, - "params": [], - }, - "interfaces": [], - "kind": "contract", - "name": "Test", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [ - { - "ast": { - "attributes": [], - "declarations": [], - "id": 2, - "kind": "trait", - "loc": trait BaseTrait {}, - "name": { - "id": 1, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", - }, - "traits": [], - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "trait", - "name": "BaseTrait", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 1020, - }, - ], - "uid": 44104, - }, -] -`; - -exports[`resolveDescriptors should resolve descriptors for override-for-non-existing-function-in-trait-without-inheritance 2`] = `[]`; +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait-with-multi-inheritance-from-base-trait 2`] = `[]`; exports[`resolveDescriptors should resolve descriptors for scope-loops 1`] = `[]`; diff --git a/src/types/test/override-for-existing-function-in-trait-with-deep-inheritance.tact b/src/types/test/override-for-existing-function-in-trait-with-deep-inheritance.tact new file mode 100644 index 000000000..7e0c97ea5 --- /dev/null +++ b/src/types/test/override-for-existing-function-in-trait-with-deep-inheritance.tact @@ -0,0 +1,11 @@ +trait BaseTrait {} + +trait T1 { fun foo() {} } + +trait T2 with T1 {} + +trait T3 with T2 {} + +contract Test with T3 { + override fun foo() {} +} From 342b33a5179187d54b6f6b55141385afb395a1e6 Mon Sep 17 00:00:00 2001 From: i582 <51853996+i582@users.noreply.github.com> Date: Tue, 14 Jan 2025 11:00:56 +0400 Subject: [PATCH 09/11] added one more test for deep inheritance --- .../resolveDescriptors.spec.ts.snap | 1420 +++++++++++++++++ ...trait-with-deep-inheritance-in-middle.tact | 11 + 2 files changed, 1431 insertions(+) create mode 100644 src/types/test/override-for-existing-function-in-trait-with-deep-inheritance-in-middle.tact diff --git a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap index 6b0bfa641..4d05f97bc 100644 --- a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap +++ b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap @@ -17674,6 +17674,1426 @@ exports[`resolveDescriptors should resolve descriptors for override-for-existing exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait-with-deep-inheritance 2`] = `[]`; +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait-with-deep-inheritance-in-middle 1`] = ` +[ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait T1 {}, + "name": { + "id": 3, + "kind": "id", + "loc": T1, + "text": "T1", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T1", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 58377, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 8, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 7, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 9, + "kind": "trait", + "loc": trait T2 with T1 { fun foo() {} }, + "name": { + "id": 5, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 6, + "kind": "id", + "loc": T1, + "text": "T1", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 8, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 7, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait T1 {}, + "name": { + "id": 3, + "kind": "id", + "loc": T1, + "text": "T1", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T1", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 58377, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 12, + "kind": "trait", + "loc": trait T3 with T2 {}, + "name": { + "id": 10, + "kind": "id", + "loc": T3, + "text": "T3", + }, + "traits": [ + { + "id": 11, + "kind": "id", + "loc": T2, + "text": "T2", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 20, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 7, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T3", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T3", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 8, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 7, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 9, + "kind": "trait", + "loc": trait T2 with T1 { fun foo() {} }, + "name": { + "id": 5, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 6, + "kind": "id", + "loc": T1, + "text": "T1", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 8, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 7, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait T1 {}, + "name": { + "id": 3, + "kind": "id", + "loc": T1, + "text": "T1", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T1", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 58377, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait T1 {}, + "name": { + "id": 3, + "kind": "id", + "loc": T1, + "text": "T1", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T1", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 58377, + }, + ], + "uid": 50251, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 16, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 15, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 17, + "kind": "contract", + "loc": contract Test with T3 { + override fun foo() {} +}, + "name": { + "id": 13, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 14, + "kind": "id", + "loc": T3, + "text": "T3", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 16, + "kind": "function_def", + "loc": override fun foo() {}, + "name": { + "id": 15, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": true, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + }, + "header": null, + "init": { + "ast": { + "id": 19, + "kind": "contract_init", + "loc": contract Test with T3 { + override fun foo() {} +}, + "params": [], + "statements": [], + }, + "params": [], + }, + "interfaces": [], + "kind": "contract", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 12, + "kind": "trait", + "loc": trait T3 with T2 {}, + "name": { + "id": 10, + "kind": "id", + "loc": T3, + "text": "T3", + }, + "traits": [ + { + "id": 11, + "kind": "id", + "loc": T2, + "text": "T2", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 20, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 7, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T3", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T3", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 8, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 7, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 9, + "kind": "trait", + "loc": trait T2 with T1 { fun foo() {} }, + "name": { + "id": 5, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 6, + "kind": "id", + "loc": T1, + "text": "T1", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 8, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 7, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait T1 {}, + "name": { + "id": 3, + "kind": "id", + "loc": T1, + "text": "T1", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T1", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 58377, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait T1 {}, + "name": { + "id": 3, + "kind": "id", + "loc": T1, + "text": "T1", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T1", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 58377, + }, + ], + "uid": 50251, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 8, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 7, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 9, + "kind": "trait", + "loc": trait T2 with T1 { fun foo() {} }, + "name": { + "id": 5, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 6, + "kind": "id", + "loc": T1, + "text": "T1", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "foo" => { + "ast": { + "attributes": [], + "id": 8, + "kind": "function_def", + "loc": fun foo() {}, + "name": { + "id": 7, + "kind": "id", + "loc": foo, + "text": "foo", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "foo", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait T1 {}, + "name": { + "id": 3, + "kind": "id", + "loc": T1, + "text": "T1", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T1", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 58377, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait T1 {}, + "name": { + "id": 3, + "kind": "id", + "loc": T1, + "text": "T1", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T1", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 58377, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait-with-deep-inheritance-in-middle 2`] = `[]`; + exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait-with-multi-inheritance 1`] = ` [ { diff --git a/src/types/test/override-for-existing-function-in-trait-with-deep-inheritance-in-middle.tact b/src/types/test/override-for-existing-function-in-trait-with-deep-inheritance-in-middle.tact new file mode 100644 index 000000000..32dc313f4 --- /dev/null +++ b/src/types/test/override-for-existing-function-in-trait-with-deep-inheritance-in-middle.tact @@ -0,0 +1,11 @@ +trait BaseTrait {} + +trait T1 {} + +trait T2 with T1 { fun foo() {} } + +trait T3 with T2 {} + +contract Test with T3 { + override fun foo() {} +} From 31286705a09b90b92ae0bb41a32976d72a52ef48 Mon Sep 17 00:00:00 2001 From: i582 <51853996+i582@users.noreply.github.com> Date: Tue, 14 Jan 2025 11:03:49 +0400 Subject: [PATCH 10/11] added diamond inheritance tests --- .../resolveDescriptors.spec.ts.snap | 1621 +++++++++++++++++ ...ion-in-trait-with-diamond-inheritance.tact | 17 + ...ion-in-trait-with-diamond-inheritance.tact | 17 + 3 files changed, 1655 insertions(+) create mode 100644 src/types/test-failed/override-for-non-existing-function-in-trait-with-diamond-inheritance.tact create mode 100644 src/types/test/override-for-existing-function-in-trait-with-diamond-inheritance.tact diff --git a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap index 4d05f97bc..e9cc46e76 100644 --- a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap +++ b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap @@ -493,6 +493,16 @@ Line 6, col 5: " `; +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-trait-with-diamond-inheritance 1`] = ` +":16:5: Function "foo" overrides nothing, remove "override" modifier +Line 16, col 5: + 15 | trait Test with T2, T3 { +> 16 | override fun foo() {} + ^~~~~~~~~~~~~~~~~~~~~ + 17 | } +" +`; + exports[`resolveDescriptors should fail descriptors for override-for-non-existing-function-in-trait-with-inheritance 1`] = ` ":5:5: Function "foo" overrides nothing, remove "override" modifier Line 5, col 5: @@ -19094,6 +19104,1617 @@ exports[`resolveDescriptors should resolve descriptors for override-for-existing exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait-with-deep-inheritance-in-middle 2`] = `[]`; +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait-with-diamond-inheritance 1`] = ` +[ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 4, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T { + fun bar() {} +}, + "name": { + "id": 3, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "bar" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 4, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 10, + "kind": "function_def", + "loc": fun baz() {}, + "name": { + "id": 9, + "kind": "id", + "loc": baz, + "text": "baz", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 11, + "kind": "trait", + "loc": trait T2 with T { + fun baz() {} +}, + "name": { + "id": 7, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 8, + "kind": "id", + "loc": T, + "text": "T", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "baz" => { + "ast": { + "attributes": [], + "id": 10, + "kind": "function_def", + "loc": fun baz() {}, + "name": { + "id": 9, + "kind": "id", + "loc": baz, + "text": "baz", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "baz", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + "bar" => { + "ast": { + "attributes": [], + "id": 26, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 4, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 4, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T { + fun bar() {} +}, + "name": { + "id": 3, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "bar" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 4, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 15, + "kind": "function_def", + "loc": fun ban() {}, + "name": { + "id": 14, + "kind": "id", + "loc": ban, + "text": "ban", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 16, + "kind": "trait", + "loc": trait T3 with T { + fun ban() {} +}, + "name": { + "id": 12, + "kind": "id", + "loc": T3, + "text": "T3", + }, + "traits": [ + { + "id": 13, + "kind": "id", + "loc": T, + "text": "T", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "ban" => { + "ast": { + "attributes": [], + "id": 15, + "kind": "function_def", + "loc": fun ban() {}, + "name": { + "id": 14, + "kind": "id", + "loc": ban, + "text": "ban", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "ban", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T3", + "optional": false, + }, + }, + "bar" => { + "ast": { + "attributes": [], + "id": 27, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 4, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T3", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T3", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 4, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T { + fun bar() {} +}, + "name": { + "id": 3, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "bar" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 4, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + ], + "uid": 50251, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 21, + "kind": "function_def", + "loc": override fun bar() {}, + "name": { + "id": 20, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 22, + "kind": "trait", + "loc": trait Test with T2, T3 { + override fun bar() {} +}, + "name": { + "id": 17, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 18, + "kind": "id", + "loc": T2, + "text": "T2", + }, + { + "id": 19, + "kind": "id", + "loc": T3, + "text": "T3", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "bar" => { + "ast": { + "attributes": [ + { + "kind": "function_attribute", + "loc": override, + "type": "override", + }, + ], + "id": 21, + "kind": "function_def", + "loc": override fun bar() {}, + "name": { + "id": 20, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": true, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + "baz" => { + "ast": { + "attributes": [], + "id": 24, + "kind": "function_def", + "loc": fun baz() {}, + "name": { + "id": 9, + "kind": "id", + "loc": baz, + "text": "baz", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "baz", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + "ban" => { + "ast": { + "attributes": [], + "id": 25, + "kind": "function_def", + "loc": fun ban() {}, + "name": { + "id": 14, + "kind": "id", + "loc": ban, + "text": "ban", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "ban", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 10, + "kind": "function_def", + "loc": fun baz() {}, + "name": { + "id": 9, + "kind": "id", + "loc": baz, + "text": "baz", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 11, + "kind": "trait", + "loc": trait T2 with T { + fun baz() {} +}, + "name": { + "id": 7, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 8, + "kind": "id", + "loc": T, + "text": "T", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "baz" => { + "ast": { + "attributes": [], + "id": 10, + "kind": "function_def", + "loc": fun baz() {}, + "name": { + "id": 9, + "kind": "id", + "loc": baz, + "text": "baz", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "baz", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + "bar" => { + "ast": { + "attributes": [], + "id": 26, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 4, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T2", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 4, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T { + fun bar() {} +}, + "name": { + "id": 3, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "bar" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 4, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 4, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T { + fun bar() {} +}, + "name": { + "id": 3, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "bar" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 4, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 15, + "kind": "function_def", + "loc": fun ban() {}, + "name": { + "id": 14, + "kind": "id", + "loc": ban, + "text": "ban", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 16, + "kind": "trait", + "loc": trait T3 with T { + fun ban() {} +}, + "name": { + "id": 12, + "kind": "id", + "loc": T3, + "text": "T3", + }, + "traits": [ + { + "id": 13, + "kind": "id", + "loc": T, + "text": "T", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "ban" => { + "ast": { + "attributes": [], + "id": 15, + "kind": "function_def", + "loc": fun ban() {}, + "name": { + "id": 14, + "kind": "id", + "loc": ban, + "text": "ban", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "ban", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T3", + "optional": false, + }, + }, + "bar" => { + "ast": { + "attributes": [], + "id": 27, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 4, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T3", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T3", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 4, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + ], + "id": 6, + "kind": "trait", + "loc": trait T { + fun bar() {} +}, + "name": { + "id": 3, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map { + "bar" => { + "ast": { + "attributes": [], + "id": 5, + "kind": "function_def", + "loc": fun bar() {}, + "name": { + "id": 4, + "kind": "id", + "loc": bar, + "text": "bar", + }, + "params": [], + "return": null, + "statements": [], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "bar", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "T", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 2, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 1, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + ], + "uid": 6769, + }, + ], + "uid": 50251, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait-with-diamond-inheritance 2`] = `[]`; + exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-trait-with-multi-inheritance 1`] = ` [ { diff --git a/src/types/test-failed/override-for-non-existing-function-in-trait-with-diamond-inheritance.tact b/src/types/test-failed/override-for-non-existing-function-in-trait-with-diamond-inheritance.tact new file mode 100644 index 000000000..afa661581 --- /dev/null +++ b/src/types/test-failed/override-for-non-existing-function-in-trait-with-diamond-inheritance.tact @@ -0,0 +1,17 @@ +trait BaseTrait {} + +trait T { + fun bar() {} +} + +trait T2 with T { + fun baz() {} +} + +trait T3 with T { + fun ban() {} +} + +trait Test with T2, T3 { + override fun foo() {} +} diff --git a/src/types/test/override-for-existing-function-in-trait-with-diamond-inheritance.tact b/src/types/test/override-for-existing-function-in-trait-with-diamond-inheritance.tact new file mode 100644 index 000000000..ddddb96ff --- /dev/null +++ b/src/types/test/override-for-existing-function-in-trait-with-diamond-inheritance.tact @@ -0,0 +1,17 @@ +trait BaseTrait {} + +trait T { + fun bar() {} +} + +trait T2 with T { + fun baz() {} +} + +trait T3 with T { + fun ban() {} +} + +trait Test with T2, T3 { + override fun bar() {} +} From 7552394be0b97df45f52608a7a9a376d06ba9009 Mon Sep 17 00:00:00 2001 From: i582 <51853996+i582@users.noreply.github.com> Date: Tue, 14 Jan 2025 12:30:06 +0400 Subject: [PATCH 11/11] fixed review issues --- CHANGELOG.md | 2 +- src/types/resolveDescriptors.ts | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd5d195ad..8e181b7cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,7 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Code generation for `self` argument in optional struct methods: PR [#1284](https://github.com/tact-lang/tact/pull/1284) - 'The "remainder" field can only be the last field:' inspection now shows location: PR [#1300](https://github.com/tact-lang/tact/pull/1300) - Forbid "remainder" field at the middle of a contract storage: PR [#1301](https://github.com/tact-lang/tact/pull/1301) -- Forbid override modifier for functions without super function: PR [#1302](https://github.com/tact-lang/tact/pull/1302) +- Forbid the `override` modifier for functions without the corresponding super-function: PR [#1302](https://github.com/tact-lang/tact/pull/1302) ### Docs diff --git a/src/types/resolveDescriptors.ts b/src/types/resolveDescriptors.ts index e03b39049..5fc005d6d 100644 --- a/src/types/resolveDescriptors.ts +++ b/src/types/resolveDescriptors.ts @@ -1570,14 +1570,8 @@ export function resolveDescriptors(ctx: CompilerContext, Ast: FactoryAst) { continue; } - const foundOverriddenFunction = contractOrTrait.traits.some( - (inheritedTrait) => { - return ( - inheritedTrait.functions.get( - funInContractOrTrait.name, - ) !== undefined - ); - }, + const foundOverriddenFunction = contractOrTrait.traits.some((t) => + t.functions.has(funInContractOrTrait.name), ); if (!foundOverriddenFunction) {