From 3b351ede92c187bc30445a6206f0c8eeb91e8f46 Mon Sep 17 00:00:00 2001 From: i582 <51853996+i582@users.noreply.github.com> Date: Wed, 5 Feb 2025 16:00:20 +0400 Subject: [PATCH] check that the overridden constant has a super constant Fixes #1713 --- .../base-trait-constant-override-2.tact | 6 +- .../resolveDescriptors.spec.ts.snap | 7143 +++++++++++++++++ src/types/resolveDescriptors.ts | 24 + ...-constant-in-contract-from-base-trait.tact | 9 + ...nt-in-contract-with-multi-inheritance.tact | 14 + ...stant-in-contract-without-inheritance.tact | 7 + ...ing-constant-in-trait-from-base-trait.tact | 9 + ...stant-in-trait-with-multi-inheritance.tact | 14 + ...constant-in-trait-without-inheritance.tact | 7 + ...-constant-in-contract-from-base-trait.tact | 9 + ...ith-multi-inheritance-from-base-trait.tact | 17 + ...nt-in-contract-with-multi-inheritance.tact | 12 + ...ide-for-existing-constant-in-contract.tact | 10 + ...ing-constant-in-trait-from-base-trait.tact | 9 + ...trait-with-deep-inheritance-in-middle.tact | 13 + ...ant-in-trait-with-diamond-inheritance.tact | 19 + ...ith-multi-inheritance-from-base-trait.tact | 16 + ...stant-in-trait-with-multi-inheritance.tact | 12 + ...erride-for-existing-constant-in-trait.tact | 10 + src/types/types.ts | 1 + 20 files changed, 7356 insertions(+), 5 deletions(-) create mode 100644 src/types/test-failed/override-for-non-existing-constant-in-contract-from-base-trait.tact create mode 100644 src/types/test-failed/override-for-non-existing-constant-in-contract-with-multi-inheritance.tact create mode 100644 src/types/test-failed/override-for-non-existing-constant-in-contract-without-inheritance.tact create mode 100644 src/types/test-failed/override-for-non-existing-constant-in-trait-from-base-trait.tact create mode 100644 src/types/test-failed/override-for-non-existing-constant-in-trait-with-multi-inheritance.tact create mode 100644 src/types/test-failed/override-for-non-existing-constant-in-trait-without-inheritance.tact create mode 100644 src/types/test/override-for-existing-constant-in-contract-from-base-trait.tact create mode 100644 src/types/test/override-for-existing-constant-in-contract-with-multi-inheritance-from-base-trait.tact create mode 100644 src/types/test/override-for-existing-constant-in-contract-with-multi-inheritance.tact create mode 100644 src/types/test/override-for-existing-constant-in-contract.tact create mode 100644 src/types/test/override-for-existing-constant-in-trait-from-base-trait.tact create mode 100644 src/types/test/override-for-existing-constant-in-trait-with-deep-inheritance-in-middle.tact create mode 100644 src/types/test/override-for-existing-constant-in-trait-with-diamond-inheritance.tact create mode 100644 src/types/test/override-for-existing-constant-in-trait-with-multi-inheritance-from-base-trait.tact create mode 100644 src/types/test/override-for-existing-constant-in-trait-with-multi-inheritance.tact create mode 100644 src/types/test/override-for-existing-constant-in-trait.tact diff --git a/src/test/e2e-emulated/contracts/base-trait-constant-override-2.tact b/src/test/e2e-emulated/contracts/base-trait-constant-override-2.tact index 58503af38..3395fb501 100644 --- a/src/test/e2e-emulated/contracts/base-trait-constant-override-2.tact +++ b/src/test/e2e-emulated/contracts/base-trait-constant-override-2.tact @@ -1,8 +1,4 @@ -trait OverrideBaseTraitConstant with BaseTrait { - override const storageReserve: Int = 100; -} - -trait OverrideBaseTraitConstantWithVirtual { +trait OverrideBaseTraitConstantWithVirtual with BaseTrait { override virtual const storageReserve: Int = 100; } diff --git a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap index 38198f738..a9675fc80 100644 --- a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap +++ b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap @@ -495,6 +495,60 @@ exports[`resolveDescriptors should fail descriptors for native-fun-getter 1`] = " `; +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-constant-in-contract-from-base-trait 1`] = ` +":8:5: Constant "BAR" overrides nothing, remove "override" modifier or inherit any traits with this constant + 7 | contract Test { +> 8 | override const BAR: Int = 10; + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 9 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-constant-in-contract-with-multi-inheritance 1`] = ` +":13:5: Constant "FOO" overrides nothing, remove "override" modifier + 12 | contract Test with T, T2 { +> 13 | override const FOO: Int = 10; + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 14 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-constant-in-contract-without-inheritance 1`] = ` +":6:5: Constant "FOO" overrides nothing, remove "override" modifier or inherit any traits with this constant + 5 | contract Test { +> 6 | override const FOO: Int = 100; + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 7 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-constant-in-trait-from-base-trait 1`] = ` +":8:5: Constant "BAR" overrides nothing, remove "override" modifier or inherit any traits with this constant + 7 | trait Test { +> 8 | override const BAR: Int = 10; + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 9 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-constant-in-trait-with-multi-inheritance 1`] = ` +":13:5: Constant "FOO" overrides nothing, remove "override" modifier + 12 | trait Test with T, T2 { +> 13 | override const FOO: Int = 10; + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 14 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for override-for-non-existing-constant-in-trait-without-inheritance 1`] = ` +":6:5: Constant "FOO" overrides nothing, remove "override" modifier or inherit any traits with this constant + 5 | trait Test { +> 6 | override const FOO: Int = 100; + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 7 | } +" +`; + 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 5 | contract Test { @@ -3478,6 +3532,7 @@ exports[`resolveDescriptors should resolve descriptors for contract-const-overri "text": "Int", }, }, + "isOverride": false, "loc": abstract const Foo: Int;, "name": "Foo", "type": { @@ -3591,6 +3646,7 @@ exports[`resolveDescriptors should resolve descriptors for contract-const-overri "text": "Int", }, }, + "isOverride": true, "loc": override const Foo: Int = 42;, "name": "Foo", "type": { @@ -3730,6 +3786,7 @@ exports[`resolveDescriptors should resolve descriptors for contract-const-overri "text": "Int", }, }, + "isOverride": false, "loc": abstract const Foo: Int;, "name": "Foo", "type": { @@ -3907,6 +3964,7 @@ exports[`resolveDescriptors should resolve descriptors for contract-const-overri "text": "Int", }, }, + "isOverride": false, "loc": virtual const Foo: Int = 41;, "name": "Foo", "type": { @@ -4026,6 +4084,7 @@ exports[`resolveDescriptors should resolve descriptors for contract-const-overri "text": "Int", }, }, + "isOverride": true, "loc": override const Foo: Int = 42;, "name": "Foo", "type": { @@ -4179,6 +4238,7 @@ exports[`resolveDescriptors should resolve descriptors for contract-const-overri "text": "Int", }, }, + "isOverride": false, "loc": virtual const Foo: Int = 41;, "name": "Foo", "type": { @@ -13675,6 +13735,7089 @@ 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-constant-function-in-trait-with-diamond-inheritance 1`] = ` +[ + { + "ast": { + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, + "name": { + "id": 1, + "kind": "id", + "loc": Int, + "text": "Int", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Int", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 38154, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 3, + "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": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait T { + const BAR: Int = 100; +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 16, + "initializer": { + "base": 10, + "id": 15, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAZ: Int = 100;, + "name": { + "id": 13, + "kind": "id", + "loc": BAZ, + "text": "BAZ", + }, + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 17, + "kind": "trait", + "loc": trait T2 with T { + const BAZ: Int = 100; +}, + "name": { + "id": 11, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 12, + "kind": "id", + "loc": T, + "text": "T", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 16, + "initializer": { + "base": 10, + "id": 15, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAZ: Int = 100;, + "name": { + "id": 13, + "kind": "id", + "loc": BAZ, + "text": "BAZ", + }, + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAZ: Int = 100;, + "name": "BAZ", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 15, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + { + "ast": { + "attributes": [], + "id": 39, + "initializer": { + "base": 10, + "id": 38, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 37, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 38, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait T { + const BAR: Int = 100; +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 6769, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 23, + "initializer": { + "base": 10, + "id": 22, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 20, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 21, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 24, + "kind": "trait", + "loc": trait T3 with T { + override const BAR: Int = 100; +}, + "name": { + "id": 18, + "kind": "id", + "loc": T3, + "text": "T3", + }, + "traits": [ + { + "id": 19, + "kind": "id", + "loc": T, + "text": "T", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 23, + "initializer": { + "base": 10, + "id": 22, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 20, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 21, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": true, + "loc": override const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 22, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T3", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait T { + const BAR: Int = 100; +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 6769, + }, + ], + "uid": 50251, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 31, + "initializer": { + "base": 10, + "id": 30, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 28, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 29, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 32, + "kind": "trait", + "loc": trait Test with T2, T3 { + override const BAR: Int = 100; +}, + "name": { + "id": 25, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 26, + "kind": "id", + "loc": T2, + "text": "T2", + }, + { + "id": 27, + "kind": "id", + "loc": T3, + "text": "T3", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 31, + "initializer": { + "base": 10, + "id": 30, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 28, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 29, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": true, + "loc": override const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 30, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + { + "ast": { + "attributes": [], + "id": 36, + "initializer": { + "base": 10, + "id": 35, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAZ: Int = 100;, + "name": { + "id": 13, + "kind": "id", + "loc": BAZ, + "text": "BAZ", + }, + "type": { + "id": 34, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAZ: Int = 100;, + "name": "BAZ", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 35, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 16, + "initializer": { + "base": 10, + "id": 15, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAZ: Int = 100;, + "name": { + "id": 13, + "kind": "id", + "loc": BAZ, + "text": "BAZ", + }, + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 17, + "kind": "trait", + "loc": trait T2 with T { + const BAZ: Int = 100; +}, + "name": { + "id": 11, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 12, + "kind": "id", + "loc": T, + "text": "T", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 16, + "initializer": { + "base": 10, + "id": 15, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAZ: Int = 100;, + "name": { + "id": 13, + "kind": "id", + "loc": BAZ, + "text": "BAZ", + }, + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAZ: Int = 100;, + "name": "BAZ", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 15, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + { + "ast": { + "attributes": [], + "id": 39, + "initializer": { + "base": 10, + "id": 38, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 37, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 38, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait T { + const BAR: Int = 100; +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 6769, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait T { + const BAR: Int = 100; +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 23, + "initializer": { + "base": 10, + "id": 22, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 20, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 21, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 24, + "kind": "trait", + "loc": trait T3 with T { + override const BAR: Int = 100; +}, + "name": { + "id": 18, + "kind": "id", + "loc": T3, + "text": "T3", + }, + "traits": [ + { + "id": 19, + "kind": "id", + "loc": T, + "text": "T", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 23, + "initializer": { + "base": 10, + "id": 22, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 20, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 21, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": true, + "loc": override const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 22, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T3", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait T { + const BAR: Int = 100; +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 6769, + }, + ], + "uid": 50251, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-constant-function-in-trait-with-diamond-inheritance 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-constant-in-contract 1`] = ` +[ + { + "ast": { + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, + "name": { + "id": 1, + "kind": "id", + "loc": Int, + "text": "Int", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Int", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 38154, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 3, + "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": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 10, + "value": 10n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 10;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait T { + const BAR: Int = 10; +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 10, + "value": 10n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 10;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 10;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 10, + "value": 10n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 16, + "initializer": { + "base": 10, + "id": 15, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 13, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 17, + "kind": "contract", + "loc": contract Test with T { + override const BAR: Int = 100; +}, + "name": { + "id": 11, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 12, + "kind": "id", + "loc": T, + "text": "T", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 16, + "initializer": { + "base": 10, + "id": 15, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 13, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": true, + "loc": override const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 15, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": { + "ast": { + "id": 19, + "kind": "contract_init", + "loc": contract Test with T { + override const BAR: Int = 100; +}, + "params": [], + "statements": [], + }, + "params": [], + }, + "interfaces": [], + "kind": "contract", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 3, + "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": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 10, + "value": 10n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 10;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait T { + const BAR: Int = 10; +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 10, + "value": 10n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 10;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 10;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 10, + "value": 10n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 6769, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-constant-in-contract 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-constant-in-contract-from-base-trait 1`] = ` +[ + { + "ast": { + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, + "name": { + "id": 1, + "kind": "id", + "loc": Int, + "text": "Int", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Int", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 38154, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 8, + "kind": "trait", + "loc": trait BaseTrait { + const BAR: Int = 100; +}, + "name": { + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "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": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 14, + "initializer": { + "base": 10, + "id": 13, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 11, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 12, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 15, + "kind": "contract", + "loc": contract Test with BaseTrait { + override const BAR: Int = 100; +}, + "name": { + "id": 9, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 10, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 14, + "initializer": { + "base": 10, + "id": 13, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 11, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 12, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": true, + "loc": override const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 13, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": { + "ast": { + "id": 17, + "kind": "contract_init", + "loc": contract Test with BaseTrait { + override const BAR: Int = 100; +}, + "params": [], + "statements": [], + }, + "params": [], + }, + "interfaces": [], + "kind": "contract", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 8, + "kind": "trait", + "loc": trait BaseTrait { + const BAR: Int = 100; +}, + "name": { + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "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-existing-constant-in-contract-from-base-trait 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-constant-in-contract-with-multi-inheritance 1`] = ` +[ + { + "ast": { + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, + "name": { + "id": 1, + "kind": "id", + "loc": Int, + "text": "Int", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Int", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 38154, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 3, + "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": 6, + "kind": "trait", + "loc": trait T {}, + "name": { + "id": 5, + "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": [], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 11, + "initializer": { + "base": 10, + "id": 10, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 8, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 9, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 12, + "kind": "trait", + "loc": trait T2 { + const BAR: Int = 100; +}, + "name": { + "id": 7, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 11, + "initializer": { + "base": 10, + "id": 10, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 8, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 9, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 10, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 19, + "initializer": { + "base": 10, + "id": 18, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 16, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 17, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 20, + "kind": "contract", + "loc": contract Test with T, T2 { + override const BAR: Int = 100; +}, + "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": [ + { + "ast": { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 19, + "initializer": { + "base": 10, + "id": 18, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 16, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 17, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": true, + "loc": override const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 18, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": { + "ast": { + "id": 22, + "kind": "contract_init", + "loc": contract Test with T, T2 { + override const BAR: Int = 100; +}, + "params": [], + "statements": [], + }, + "params": [], + }, + "interfaces": [], + "kind": "contract", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 3, + "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": 6, + "kind": "trait", + "loc": trait T {}, + "name": { + "id": 5, + "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": [], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 11, + "initializer": { + "base": 10, + "id": 10, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 8, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 9, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 12, + "kind": "trait", + "loc": trait T2 { + const BAR: Int = 100; +}, + "name": { + "id": 7, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 11, + "initializer": { + "base": 10, + "id": 10, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 8, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 9, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 10, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 54378, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-constant-in-contract-with-multi-inheritance 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-constant-in-contract-with-multi-inheritance-from-base-trait 1`] = ` +[ + { + "ast": { + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, + "name": { + "id": 1, + "kind": "id", + "loc": Int, + "text": "Int", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Int", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 38154, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const FOO: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 8, + "kind": "trait", + "loc": trait BaseTrait { + const FOO: Int = 100; +}, + "name": { + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const FOO: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const FOO: Int = 100;, + "name": "FOO", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "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": 13, + "initializer": { + "base": 10, + "id": 12, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 10, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 11, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 14, + "kind": "trait", + "loc": trait T { + const BAR: Int = 100; +}, + "name": { + "id": 9, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 13, + "initializer": { + "base": 10, + "id": 12, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 10, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 11, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 12, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 19, + "initializer": { + "base": 10, + "id": 18, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAZ: Int = 100;, + "name": { + "id": 16, + "kind": "id", + "loc": BAZ, + "text": "BAZ", + }, + "type": { + "id": 17, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 20, + "kind": "trait", + "loc": trait T2 { + const BAZ: Int = 100; +}, + "name": { + "id": 15, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 19, + "initializer": { + "base": 10, + "id": 18, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAZ: Int = 100;, + "name": { + "id": 16, + "kind": "id", + "loc": BAZ, + "text": "BAZ", + }, + "type": { + "id": 17, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAZ: Int = 100;, + "name": "BAZ", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 18, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 27, + "initializer": { + "base": 10, + "id": 26, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const FOO: Int = 100;, + "name": { + "id": 24, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 25, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 28, + "kind": "contract", + "loc": contract Test with T, T2 { + override const FOO: Int = 100; +}, + "name": { + "id": 21, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 22, + "kind": "id", + "loc": T, + "text": "T", + }, + { + "id": 23, + "kind": "id", + "loc": T2, + "text": "T2", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 27, + "initializer": { + "base": 10, + "id": 26, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const FOO: Int = 100;, + "name": { + "id": 24, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 25, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": true, + "loc": override const FOO: Int = 100;, + "name": "FOO", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 26, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + { + "ast": { + "attributes": [], + "id": 33, + "initializer": { + "base": 10, + "id": 32, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 10, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 31, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 32, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + { + "ast": { + "attributes": [], + "id": 36, + "initializer": { + "base": 10, + "id": 35, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAZ: Int = 100;, + "name": { + "id": 16, + "kind": "id", + "loc": BAZ, + "text": "BAZ", + }, + "type": { + "id": 34, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAZ: Int = 100;, + "name": "BAZ", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 35, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": { + "ast": { + "id": 30, + "kind": "contract_init", + "loc": contract Test with T, T2 { + override const FOO: Int = 100; +}, + "params": [], + "statements": [], + }, + "params": [], + }, + "interfaces": [], + "kind": "contract", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const FOO: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 8, + "kind": "trait", + "loc": trait BaseTrait { + const FOO: Int = 100; +}, + "name": { + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const FOO: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const FOO: Int = 100;, + "name": "FOO", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "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": 13, + "initializer": { + "base": 10, + "id": 12, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 10, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 11, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 14, + "kind": "trait", + "loc": trait T { + const BAR: Int = 100; +}, + "name": { + "id": 9, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 13, + "initializer": { + "base": 10, + "id": 12, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 10, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 11, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 12, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 19, + "initializer": { + "base": 10, + "id": 18, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAZ: Int = 100;, + "name": { + "id": 16, + "kind": "id", + "loc": BAZ, + "text": "BAZ", + }, + "type": { + "id": 17, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 20, + "kind": "trait", + "loc": trait T2 { + const BAZ: Int = 100; +}, + "name": { + "id": 15, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 19, + "initializer": { + "base": 10, + "id": 18, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAZ: Int = 100;, + "name": { + "id": 16, + "kind": "id", + "loc": BAZ, + "text": "BAZ", + }, + "type": { + "id": 17, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAZ: Int = 100;, + "name": "BAZ", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 18, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 54378, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-constant-in-contract-with-multi-inheritance-from-base-trait 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-constant-in-trait 1`] = ` +[ + { + "ast": { + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, + "name": { + "id": 1, + "kind": "id", + "loc": Int, + "text": "Int", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Int", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 38154, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 3, + "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": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 10, + "value": 10n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 10;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait T { + const BAR: Int = 10; +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 10, + "value": 10n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 10;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 10;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 10, + "value": 10n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 16, + "initializer": { + "base": 10, + "id": 15, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 13, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 17, + "kind": "trait", + "loc": trait Test with T { + override const BAR: Int = 100; +}, + "name": { + "id": 11, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 12, + "kind": "id", + "loc": T, + "text": "T", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 16, + "initializer": { + "base": 10, + "id": 15, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 13, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": true, + "loc": override const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 15, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 10, + "value": 10n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 10;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait T { + const BAR: Int = 10; +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 9, + "initializer": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 10, + "value": 10n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 10;, + "name": { + "id": 6, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 10;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 8, + "kind": "number", + "loc": 10, + "value": 10n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 6769, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-constant-in-trait 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-constant-in-trait-from-base-trait 1`] = ` +[ + { + "ast": { + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, + "name": { + "id": 1, + "kind": "id", + "loc": Int, + "text": "Int", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Int", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 38154, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 8, + "kind": "trait", + "loc": trait BaseTrait { + const BAR: Int = 100; +}, + "name": { + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "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": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 14, + "initializer": { + "base": 10, + "id": 13, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 11, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 12, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 15, + "kind": "trait", + "loc": trait Test with BaseTrait { + override const BAR: Int = 100; +}, + "name": { + "id": 9, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 10, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 14, + "initializer": { + "base": 10, + "id": 13, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 11, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 12, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": true, + "loc": override const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 13, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 8, + "kind": "trait", + "loc": trait BaseTrait { + const BAR: Int = 100; +}, + "name": { + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "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-existing-constant-in-trait-from-base-trait 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-constant-in-trait-with-deep-inheritance-in-middle 1`] = ` +[ + { + "ast": { + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, + "name": { + "id": 1, + "kind": "id", + "loc": Int, + "text": "Int", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Int", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 38154, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 3, + "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": 6, + "kind": "trait", + "loc": trait T1 {}, + "name": { + "id": 5, + "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": [], + "uid": 58377, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 12, + "initializer": { + "base": 10, + "id": 11, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 9, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 10, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 13, + "kind": "trait", + "loc": trait T2 with T1 { const BAR: Int = 100; }, + "name": { + "id": 7, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 8, + "kind": "id", + "loc": T1, + "text": "T1", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 12, + "initializer": { + "base": 10, + "id": 11, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 9, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 10, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 11, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 6, + "kind": "trait", + "loc": trait T1 {}, + "name": { + "id": 5, + "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": [], + "uid": 58377, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 16, + "kind": "trait", + "loc": trait T3 with T2 {}, + "name": { + "id": 14, + "kind": "id", + "loc": T3, + "text": "T3", + }, + "traits": [ + { + "id": 15, + "kind": "id", + "loc": T2, + "text": "T2", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 28, + "initializer": { + "base": 10, + "id": 27, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 9, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 26, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 27, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T3", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 12, + "initializer": { + "base": 10, + "id": 11, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 9, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 10, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 13, + "kind": "trait", + "loc": trait T2 with T1 { const BAR: Int = 100; }, + "name": { + "id": 7, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 8, + "kind": "id", + "loc": T1, + "text": "T1", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 12, + "initializer": { + "base": 10, + "id": 11, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 9, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 10, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 11, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 6, + "kind": "trait", + "loc": trait T1 {}, + "name": { + "id": 5, + "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": [], + "uid": 58377, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 6, + "kind": "trait", + "loc": trait T1 {}, + "name": { + "id": 5, + "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": [], + "uid": 58377, + }, + ], + "uid": 50251, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 22, + "initializer": { + "base": 10, + "id": 21, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 19, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 20, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 23, + "kind": "contract", + "loc": contract Test with T3 { + override const BAR: Int = 100; +}, + "name": { + "id": 17, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 18, + "kind": "id", + "loc": T3, + "text": "T3", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 22, + "initializer": { + "base": 10, + "id": 21, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 19, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 20, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": true, + "loc": override const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 21, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": { + "ast": { + "id": 25, + "kind": "contract_init", + "loc": contract Test with T3 { + override const BAR: Int = 100; +}, + "params": [], + "statements": [], + }, + "params": [], + }, + "interfaces": [], + "kind": "contract", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 3, + "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": 16, + "kind": "trait", + "loc": trait T3 with T2 {}, + "name": { + "id": 14, + "kind": "id", + "loc": T3, + "text": "T3", + }, + "traits": [ + { + "id": 15, + "kind": "id", + "loc": T2, + "text": "T2", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 28, + "initializer": { + "base": 10, + "id": 27, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 9, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 26, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 27, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T3", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 12, + "initializer": { + "base": 10, + "id": 11, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 9, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 10, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 13, + "kind": "trait", + "loc": trait T2 with T1 { const BAR: Int = 100; }, + "name": { + "id": 7, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 8, + "kind": "id", + "loc": T1, + "text": "T1", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 12, + "initializer": { + "base": 10, + "id": 11, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 9, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 10, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 11, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 6, + "kind": "trait", + "loc": trait T1 {}, + "name": { + "id": 5, + "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": [], + "uid": 58377, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 6, + "kind": "trait", + "loc": trait T1 {}, + "name": { + "id": 5, + "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": [], + "uid": 58377, + }, + ], + "uid": 50251, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 12, + "initializer": { + "base": 10, + "id": 11, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 9, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 10, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 13, + "kind": "trait", + "loc": trait T2 with T1 { const BAR: Int = 100; }, + "name": { + "id": 7, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 8, + "kind": "id", + "loc": T1, + "text": "T1", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 12, + "initializer": { + "base": 10, + "id": 11, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 9, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 10, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 11, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 6, + "kind": "trait", + "loc": trait T1 {}, + "name": { + "id": 5, + "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": [], + "uid": 58377, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 6, + "kind": "trait", + "loc": trait T1 {}, + "name": { + "id": 5, + "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": [], + "uid": 58377, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-constant-in-trait-with-deep-inheritance-in-middle 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-constant-in-trait-with-multi-inheritance 1`] = ` +[ + { + "ast": { + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, + "name": { + "id": 1, + "kind": "id", + "loc": Int, + "text": "Int", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Int", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 38154, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait {}, + "name": { + "id": 3, + "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": 6, + "kind": "trait", + "loc": trait T {}, + "name": { + "id": 5, + "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": [], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 11, + "initializer": { + "base": 10, + "id": 10, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 8, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 9, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 12, + "kind": "trait", + "loc": trait T2 { + const BAR: Int = 100; +}, + "name": { + "id": 7, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 11, + "initializer": { + "base": 10, + "id": 10, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 8, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 9, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 10, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 19, + "initializer": { + "base": 10, + "id": 18, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 16, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 17, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 20, + "kind": "trait", + "loc": trait Test with T, T2 { + override const BAR: Int = 100; +}, + "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": [ + { + "ast": { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 19, + "initializer": { + "base": 10, + "id": 18, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const BAR: Int = 100;, + "name": { + "id": 16, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 17, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": true, + "loc": override const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 18, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 6, + "kind": "trait", + "loc": trait T {}, + "name": { + "id": 5, + "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": [], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 11, + "initializer": { + "base": 10, + "id": 10, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 8, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 9, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 12, + "kind": "trait", + "loc": trait T2 { + const BAR: Int = 100; +}, + "name": { + "id": 7, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 11, + "initializer": { + "base": 10, + "id": 10, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 8, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 9, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 10, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 54378, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-constant-in-trait-with-multi-inheritance 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-constant-in-trait-with-multi-inheritance-from-base-trait 1`] = ` +[ + { + "ast": { + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, + "name": { + "id": 1, + "kind": "id", + "loc": Int, + "text": "Int", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Int", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 38154, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const FOO: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 8, + "kind": "trait", + "loc": trait BaseTrait { + const FOO: Int = 100; +}, + "name": { + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const FOO: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const FOO: Int = 100;, + "name": "FOO", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "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": 14, + "initializer": { + "base": 10, + "id": 13, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 11, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 12, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 15, + "kind": "trait", + "loc": trait T with BaseTrait { + const BAR: Int = 100; +}, + "name": { + "id": 9, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [ + { + "id": 10, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 14, + "initializer": { + "base": 10, + "id": 13, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 11, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 12, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 13, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + { + "ast": { + "attributes": [], + "id": 39, + "initializer": { + "base": 10, + "id": 38, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const FOO: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 37, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const FOO: Int = 100;, + "name": "FOO", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 38, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "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": [ + { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const FOO: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 8, + "kind": "trait", + "loc": trait BaseTrait { + const FOO: Int = 100; +}, + "name": { + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const FOO: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const FOO: Int = 100;, + "name": "FOO", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "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": 20, + "initializer": { + "base": 10, + "id": 19, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAZ: Int = 100;, + "name": { + "id": 17, + "kind": "id", + "loc": BAZ, + "text": "BAZ", + }, + "type": { + "id": 18, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 21, + "kind": "trait", + "loc": trait T2 { + const BAZ: Int = 100; +}, + "name": { + "id": 16, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 20, + "initializer": { + "base": 10, + "id": 19, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAZ: Int = 100;, + "name": { + "id": 17, + "kind": "id", + "loc": BAZ, + "text": "BAZ", + }, + "type": { + "id": 18, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAZ: Int = 100;, + "name": "BAZ", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 19, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 28, + "initializer": { + "base": 10, + "id": 27, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const FOO: Int = 100;, + "name": { + "id": 25, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 26, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 29, + "kind": "trait", + "loc": trait Test with T, T2 { + override const FOO: Int = 100; +}, + "name": { + "id": 22, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 23, + "kind": "id", + "loc": T, + "text": "T", + }, + { + "id": 24, + "kind": "id", + "loc": T2, + "text": "T2", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [ + { + "loc": override, + "type": "override", + }, + ], + "id": 28, + "initializer": { + "base": 10, + "id": 27, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": override const FOO: Int = 100;, + "name": { + "id": 25, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 26, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": true, + "loc": override const FOO: Int = 100;, + "name": "FOO", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 27, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + { + "ast": { + "attributes": [], + "id": 33, + "initializer": { + "base": 10, + "id": 32, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 11, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 31, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 32, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + { + "ast": { + "attributes": [], + "id": 36, + "initializer": { + "base": 10, + "id": 35, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAZ: Int = 100;, + "name": { + "id": 17, + "kind": "id", + "loc": BAZ, + "text": "BAZ", + }, + "type": { + "id": 34, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAZ: Int = 100;, + "name": "BAZ", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 35, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Test", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [ + { + "attributes": [], + "id": 14, + "initializer": { + "base": 10, + "id": 13, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 11, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 12, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 15, + "kind": "trait", + "loc": trait T with BaseTrait { + const BAR: Int = 100; +}, + "name": { + "id": 9, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [ + { + "id": 10, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + ], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 14, + "initializer": { + "base": 10, + "id": 13, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAR: Int = 100;, + "name": { + "id": 11, + "kind": "id", + "loc": BAR, + "text": "BAR", + }, + "type": { + "id": 12, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAR: Int = 100;, + "name": "BAR", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 13, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + { + "ast": { + "attributes": [], + "id": 39, + "initializer": { + "base": 10, + "id": 38, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const FOO: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 37, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const FOO: Int = 100;, + "name": "FOO", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 38, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "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": [ + { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const FOO: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 8, + "kind": "trait", + "loc": trait BaseTrait { + const FOO: Int = 100; +}, + "name": { + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const FOO: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const FOO: Int = 100;, + "name": "FOO", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "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, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const FOO: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 8, + "kind": "trait", + "loc": trait BaseTrait { + const FOO: Int = 100; +}, + "name": { + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 7, + "initializer": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const FOO: Int = 100;, + "name": { + "id": 4, + "kind": "id", + "loc": FOO, + "text": "FOO", + }, + "type": { + "id": 5, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const FOO: Int = 100;, + "name": "FOO", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 6, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "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": 20, + "initializer": { + "base": 10, + "id": 19, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAZ: Int = 100;, + "name": { + "id": 17, + "kind": "id", + "loc": BAZ, + "text": "BAZ", + }, + "type": { + "id": 18, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 21, + "kind": "trait", + "loc": trait T2 { + const BAZ: Int = 100; +}, + "name": { + "id": 16, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [], + }, + "constants": [ + { + "ast": { + "attributes": [], + "id": 20, + "initializer": { + "base": 10, + "id": 19, + "kind": "number", + "loc": 100, + "value": 100n, + }, + "kind": "constant_def", + "loc": const BAZ: Int = 100;, + "name": { + "id": 17, + "kind": "id", + "loc": BAZ, + "text": "BAZ", + }, + "type": { + "id": 18, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "isOverride": false, + "loc": const BAZ: Int = 100;, + "name": "BAZ", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "value": { + "base": 10, + "id": 19, + "kind": "number", + "loc": 100, + "value": 100n, + }, + }, + ], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T2", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 54378, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for override-for-existing-constant-in-trait-with-multi-inheritance-from-base-trait 2`] = `[]`; + exports[`resolveDescriptors should resolve descriptors for override-for-existing-function-in-contract 1`] = ` [ { diff --git a/src/types/resolveDescriptors.ts b/src/types/resolveDescriptors.ts index 769b69e03..81cae3e78 100644 --- a/src/types/resolveDescriptors.ts +++ b/src/types/resolveDescriptors.ts @@ -428,10 +428,12 @@ export function resolveDescriptors(ctx: CompilerContext, Ast: FactoryAst) { src: A.AstConstantDef | A.AstConstantDecl, ): ConstantDescription { const constDeclTy = buildTypeRef(src.type, types); + const isOverride = src.attributes.find((a) => a.type === "override"); return { name: idText(src.name), type: constDeclTy, value: undefined, // initializer will be evaluated after typechecking + isOverride: !!isOverride, loc: src.loc, ast: src, }; @@ -1614,6 +1616,28 @@ export function resolveDescriptors(ctx: CompilerContext, Ast: FactoryAst) { } } + // Check that "override" constants have a super constant + for (const constantInContractOrTrait of contractOrTrait.constants.values()) { + if (!constantInContractOrTrait.isOverride) { + continue; + } + + const foundOverriddenConstant = contractOrTrait.traits.some((t) => + t.constants.some( + (c) => c.name === constantInContractOrTrait.name, + ), + ); + + if (!foundOverriddenConstant) { + const msg = + contractOrTrait.traits.length === 0 || inheritOnlyBaseTrait + ? `Constant "${constantInContractOrTrait.name}" overrides nothing, remove "override" modifier or inherit any traits with this constant` + : `Constant "${constantInContractOrTrait.name}" overrides nothing, remove "override" modifier`; + + throwCompilationError(msg, constantInContractOrTrait.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-constant-in-contract-from-base-trait.tact b/src/types/test-failed/override-for-non-existing-constant-in-contract-from-base-trait.tact new file mode 100644 index 000000000..a63f1117a --- /dev/null +++ b/src/types/test-failed/override-for-non-existing-constant-in-contract-from-base-trait.tact @@ -0,0 +1,9 @@ +primitive Int; + +trait BaseTrait { + const FOO: Int = 10; +} + +contract Test { + override const BAR: Int = 10; +} diff --git a/src/types/test-failed/override-for-non-existing-constant-in-contract-with-multi-inheritance.tact b/src/types/test-failed/override-for-non-existing-constant-in-contract-with-multi-inheritance.tact new file mode 100644 index 000000000..fe2ab9154 --- /dev/null +++ b/src/types/test-failed/override-for-non-existing-constant-in-contract-with-multi-inheritance.tact @@ -0,0 +1,14 @@ +primitive Int; + +trait BaseTrait {} +trait T { + const BAR: Int = 10; +} + +trait T2 { + const BAZ: Int = 10; +} + +contract Test with T, T2 { + override const FOO: Int = 10; +} diff --git a/src/types/test-failed/override-for-non-existing-constant-in-contract-without-inheritance.tact b/src/types/test-failed/override-for-non-existing-constant-in-contract-without-inheritance.tact new file mode 100644 index 000000000..5cebcce96 --- /dev/null +++ b/src/types/test-failed/override-for-non-existing-constant-in-contract-without-inheritance.tact @@ -0,0 +1,7 @@ +primitive Int; + +trait BaseTrait {} + +contract Test { + override const FOO: Int = 100; +} diff --git a/src/types/test-failed/override-for-non-existing-constant-in-trait-from-base-trait.tact b/src/types/test-failed/override-for-non-existing-constant-in-trait-from-base-trait.tact new file mode 100644 index 000000000..6a3f1f1dd --- /dev/null +++ b/src/types/test-failed/override-for-non-existing-constant-in-trait-from-base-trait.tact @@ -0,0 +1,9 @@ +primitive Int; + +trait BaseTrait { + const FOO: Int = 10; +} + +trait Test { + override const BAR: Int = 10; +} diff --git a/src/types/test-failed/override-for-non-existing-constant-in-trait-with-multi-inheritance.tact b/src/types/test-failed/override-for-non-existing-constant-in-trait-with-multi-inheritance.tact new file mode 100644 index 000000000..770730c89 --- /dev/null +++ b/src/types/test-failed/override-for-non-existing-constant-in-trait-with-multi-inheritance.tact @@ -0,0 +1,14 @@ +primitive Int; + +trait BaseTrait {} +trait T { + const BAR: Int = 10; +} + +trait T2 { + const BAZ: Int = 10; +} + +trait Test with T, T2 { + override const FOO: Int = 10; +} diff --git a/src/types/test-failed/override-for-non-existing-constant-in-trait-without-inheritance.tact b/src/types/test-failed/override-for-non-existing-constant-in-trait-without-inheritance.tact new file mode 100644 index 000000000..c9a13d053 --- /dev/null +++ b/src/types/test-failed/override-for-non-existing-constant-in-trait-without-inheritance.tact @@ -0,0 +1,7 @@ +primitive Int; + +trait BaseTrait {} + +trait Test { + override const FOO: Int = 100; +} diff --git a/src/types/test/override-for-existing-constant-in-contract-from-base-trait.tact b/src/types/test/override-for-existing-constant-in-contract-from-base-trait.tact new file mode 100644 index 000000000..917acd1b6 --- /dev/null +++ b/src/types/test/override-for-existing-constant-in-contract-from-base-trait.tact @@ -0,0 +1,9 @@ +primitive Int; + +trait BaseTrait { + const BAR: Int = 100; +} + +contract Test with BaseTrait { + override const BAR: Int = 100; +} diff --git a/src/types/test/override-for-existing-constant-in-contract-with-multi-inheritance-from-base-trait.tact b/src/types/test/override-for-existing-constant-in-contract-with-multi-inheritance-from-base-trait.tact new file mode 100644 index 000000000..615786bc1 --- /dev/null +++ b/src/types/test/override-for-existing-constant-in-contract-with-multi-inheritance-from-base-trait.tact @@ -0,0 +1,17 @@ +primitive Int; + +trait BaseTrait { + const FOO: Int = 100; +} + +trait T { + const BAR: Int = 100; +} + +trait T2 { + const BAZ: Int = 100; +} + +contract Test with T, T2 { + override const FOO: Int = 100; +} diff --git a/src/types/test/override-for-existing-constant-in-contract-with-multi-inheritance.tact b/src/types/test/override-for-existing-constant-in-contract-with-multi-inheritance.tact new file mode 100644 index 000000000..97775035c --- /dev/null +++ b/src/types/test/override-for-existing-constant-in-contract-with-multi-inheritance.tact @@ -0,0 +1,12 @@ +primitive Int; + +trait BaseTrait {} +trait T {} + +trait T2 { + const BAR: Int = 100; +} + +contract Test with T, T2 { + override const BAR: Int = 100; +} diff --git a/src/types/test/override-for-existing-constant-in-contract.tact b/src/types/test/override-for-existing-constant-in-contract.tact new file mode 100644 index 000000000..3d35974b9 --- /dev/null +++ b/src/types/test/override-for-existing-constant-in-contract.tact @@ -0,0 +1,10 @@ +primitive Int; + +trait BaseTrait {} +trait T { + const BAR: Int = 10; +} + +contract Test with T { + override const BAR: Int = 100; +} diff --git a/src/types/test/override-for-existing-constant-in-trait-from-base-trait.tact b/src/types/test/override-for-existing-constant-in-trait-from-base-trait.tact new file mode 100644 index 000000000..dad41adf9 --- /dev/null +++ b/src/types/test/override-for-existing-constant-in-trait-from-base-trait.tact @@ -0,0 +1,9 @@ +primitive Int; + +trait BaseTrait { + const BAR: Int = 100; +} + +trait Test with BaseTrait { + override const BAR: Int = 100; +} diff --git a/src/types/test/override-for-existing-constant-in-trait-with-deep-inheritance-in-middle.tact b/src/types/test/override-for-existing-constant-in-trait-with-deep-inheritance-in-middle.tact new file mode 100644 index 000000000..22173123b --- /dev/null +++ b/src/types/test/override-for-existing-constant-in-trait-with-deep-inheritance-in-middle.tact @@ -0,0 +1,13 @@ +primitive Int; + +trait BaseTrait {} + +trait T1 {} + +trait T2 with T1 { const BAR: Int = 100; } + +trait T3 with T2 {} + +trait Test with T3 { + override const BAR: Int = 100; +} diff --git a/src/types/test/override-for-existing-constant-in-trait-with-diamond-inheritance.tact b/src/types/test/override-for-existing-constant-in-trait-with-diamond-inheritance.tact new file mode 100644 index 000000000..61e20ef5e --- /dev/null +++ b/src/types/test/override-for-existing-constant-in-trait-with-diamond-inheritance.tact @@ -0,0 +1,19 @@ +primitive Int; + +trait BaseTrait {} + +trait T { + const BAR: Int = 100; +} + +trait T2 with T { + const BAZ: Int = 100; +} + +trait T3 with T { + override const BAR: Int = 100; +} + +trait Test with T2, T3 { + override const BAR: Int = 100; +} diff --git a/src/types/test/override-for-existing-constant-in-trait-with-multi-inheritance-from-base-trait.tact b/src/types/test/override-for-existing-constant-in-trait-with-multi-inheritance-from-base-trait.tact new file mode 100644 index 000000000..afe7a3674 --- /dev/null +++ b/src/types/test/override-for-existing-constant-in-trait-with-multi-inheritance-from-base-trait.tact @@ -0,0 +1,16 @@ +primitive Int; + +trait BaseTrait { + const FOO: Int = 100; +} +trait T with BaseTrait { + const BAR: Int = 100; +} + +trait T2 { + const BAZ: Int = 100; +} + +trait Test with T, T2 { + override const FOO: Int = 100; +} diff --git a/src/types/test/override-for-existing-constant-in-trait-with-multi-inheritance.tact b/src/types/test/override-for-existing-constant-in-trait-with-multi-inheritance.tact new file mode 100644 index 000000000..1fa9a74c4 --- /dev/null +++ b/src/types/test/override-for-existing-constant-in-trait-with-multi-inheritance.tact @@ -0,0 +1,12 @@ +primitive Int; + +trait BaseTrait {} +trait T {} + +trait T2 { + const BAR: Int = 100; +} + +trait Test with T, T2 { + override const BAR: Int = 100; +} diff --git a/src/types/test/override-for-existing-constant-in-trait.tact b/src/types/test/override-for-existing-constant-in-trait.tact new file mode 100644 index 000000000..c6e5bafc2 --- /dev/null +++ b/src/types/test/override-for-existing-constant-in-trait.tact @@ -0,0 +1,10 @@ +primitive Int; + +trait BaseTrait {} +trait T { + const BAR: Int = 10; +} + +trait Test with T { + override const BAR: Int = 100; +} diff --git a/src/types/types.ts b/src/types/types.ts index 48aa1b8a6..8648b37a9 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -95,6 +95,7 @@ export type ConstantDescription = { name: string; type: TypeRef; value: A.AstLiteral | undefined; + isOverride: boolean; loc: SrcInfo; ast: A.AstConstantDef | A.AstConstantDecl; };