diff --git a/CHANGELOG.md b/CHANGELOG.md index bb08c23da..6fe756447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Remove `org.ton.chain.any.v0` interface: PR [#1207](https://github.com/tact-lang/tact/pull/1207) - To reduce fees, Tact no longer stores the parent contract code in the system cell that holds all the child contract codes used in `initOf`. Instead, the `MYCODE` instruction is used: PR [#1213](https://github.com/tact-lang/tact/pull/1213) - Generated TS wrappers now use `const` where possible for variable declarations: PR [#1292](https://github.com/tact-lang/tact/pull/1292) +- Allow serialization specifiers for trait fields PR: [#1303](https://github.com/tact-lang/tact/pull/1303) ### Fixed diff --git a/src/test/e2e-emulated/contracts/sample-jetton.tact b/src/test/e2e-emulated/contracts/sample-jetton.tact index a24daf289..a47d6bd05 100644 --- a/src/test/e2e-emulated/contracts/sample-jetton.tact +++ b/src/test/e2e-emulated/contracts/sample-jetton.tact @@ -51,8 +51,8 @@ contract SampleJetton with Jetton { // ============================================================================================================ // @interface("org.ton.jetton.master") trait Jetton with Ownable { - totalSupply: Int; // Already set initially - max_supply: Int; + totalSupply: Int as coins; // Already set initially + max_supply: Int as coins; mintable: Bool; owner: Address; content: Cell; @@ -331,4 +331,4 @@ struct JettonWalletData { owner: Address; master: Address; walletCode: Cell; -} \ No newline at end of file +} diff --git a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap index e642bc735..027e1f1af 100644 --- a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap +++ b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap @@ -320,6 +320,16 @@ Line 13, col 3: " `; +exports[`resolveDescriptors should fail descriptors for contract-without-as-typed-field-inherited-with-it 1`] = ` +":10:5: Trait "Foo" requires field "f" of type "Int", but "Int as coins" given +Line 10, col 5: + 9 | contract SomeContract with Foo { +> 10 | f: Int as coins; + ^~~~~~~~~~~~~~~ + 11 | } +" +`; + exports[`resolveDescriptors should fail descriptors for expr-bitwise-not-bool-in-const1 1`] = ` ":4:16: Invalid type "Bool" for unary operator "~" Line 4, col 16: @@ -660,6 +670,106 @@ Line 2, col 14: " `; +exports[`resolveDescriptors should fail descriptors for trait-with-as-typed-field-for-contract 1`] = ` +":10:5: Trait "Foo" requires field "f" of type "Int as int32", but "Int" given +Line 10, col 5: + 9 | contract SomeContract with Foo { +> 10 | f: Int; + ^~~~~~ + 11 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for trait-with-as-typed-field-for-contract-with-other-specialization 1`] = ` +":10:5: Trait "Foo" requires field "f" of type "Int as int32", but "Int as int16" given +Line 10, col 5: + 9 | contract SomeContract with Foo { +> 10 | f: Int as int16 = 0; + ^~~~~~~~~~~~~~~~~~~ + 11 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for trait-with-as-typed-field-for-contract-with-other-type 1`] = ` +":10:1: Trait "Foo" requires field "f" of type "Int" +Line 10, col 1: + 9 | +> 10 | contract SomeContract with Foo { + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 11 | f: Cell; +" +`; + +exports[`resolveDescriptors should fail descriptors for trait-with-as-typed-field-for-trait 1`] = ` +":10:5: Trait "Foo" requires field "f" of type "Int as int32", but "Int" given +Line 10, col 5: + 9 | trait SomeTrait with Foo { +> 10 | f: Int; + ^~~~~~ + 11 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for trait-with-as-typed-field-for-trait-with-other-specialization 1`] = ` +":10:5: Trait "Foo" requires field "f" of type "Int as int32", but "Int as int16" given +Line 10, col 5: + 9 | trait SomeTrait with Foo { +> 10 | f: Int as int16; + ^~~~~~~~~~~~~~~ + 11 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for trait-with-as-typed-field-for-trait-with-other-type 1`] = ` +":10:1: Trait "Foo" requires field "f" of type "Int" +Line 10, col 1: + 9 | +> 10 | trait SomeTrait with Foo { + ^~~~~~~~~~~~~~~~~~~~~~~~~~ + 11 | f: Cell; +" +`; + +exports[`resolveDescriptors should fail descriptors for trait-with-as-typed-field-in-diamond-inheritance-and-other-specialization 1`] = ` +":21:5: Trait "T2" requires field "f2" of type "Int as int32", but "Int as int16" given +Line 21, col 5: + 20 | f1: Int as int32; +> 21 | f2: Int as int16; + ^~~~~~~~~~~~~~~~ + 22 | f3: Int as int32; +" +`; + +exports[`resolveDescriptors should fail descriptors for trait-with-as-typed-field-with-unsupported-format 1`] = ` +":6:5: Unsupported format "foo" +Line 6, col 5: + 5 | trait Foo { +> 6 | f: Int as foo; + ^~~~~~~~~~~~~ + 7 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for trait-with-as-typed-int257-field-for-trait-with-as-typed-coins-field 1`] = ` +":10:5: Trait "Trait" requires field "i" of type "Int as int257", but "Int as coins" given +Line 10, col 5: + 9 | contract Foo with Trait { +> 10 | i: Int as coins = 0; + ^~~~~~~~~~~~~~~~~~~ + 11 | } +" +`; + +exports[`resolveDescriptors should fail descriptors for trait-without-as-typed-field-inherited-with-it 1`] = ` +":10:5: Trait "Foo" requires field "f" of type "Int", but "Int as int32" given +Line 10, col 5: + 9 | trait SomeTrait with Foo { +> 10 | f: Int as int32; + ^~~~~~~~~~~~~~~ + 11 | } +" +`; + exports[`resolveDescriptors should fail descriptors for wf-type-const 1`] = ` ":4:19: Invalid map type. Check https://docs.tact-lang.org/book/maps#allowed-types Line 4, col 19: @@ -6213,7 +6323,7 @@ exports[`resolveDescriptors should resolve descriptors for contract-getter-overr exports[`resolveDescriptors should resolve descriptors for contract-getter-override-virtual 2`] = `[]`; -exports[`resolveDescriptors should resolve descriptors for fun-extends-opt-self 1`] = ` +exports[`resolveDescriptors should resolve descriptors for contract-with-as-typed-field 1`] = ` [ { "ast": { @@ -6230,225 +6340,427 @@ exports[`resolveDescriptors should resolve descriptors for fun-extends-opt-self "constants": [], "dependsOn": [], "fields": [], - "functions": Map { - "test_extends" => { - "ast": { - "attributes": [ - { - "kind": "function_attribute", - "loc": extends, - "type": "extends", - }, - ], - "id": 26, - "kind": "function_def", - "loc": extends fun test_extends(self: Int, y: Int?): Int { - return 123; -}, + "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": [ + { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f: Int as int32, "name": { - "id": 15, + "id": 6, "kind": "id", - "loc": test_extends, - "text": "test_extends", + "loc": f, + "text": "f", }, - "params": [ - { - "id": 19, - "kind": "typed_parameter", - "loc": self: Int, - "name": { - "id": 17, - "kind": "id", - "loc": self, - "text": "self", - }, - "type": { - "id": 18, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - }, - { - "id": 23, - "kind": "typed_parameter", - "loc": y: Int?, - "name": { - "id": 20, - "kind": "id", - "loc": y, - "text": "y", - }, - "type": { - "id": 22, - "kind": "optional_type", - "loc": Int?, - "typeArg": { - "id": 21, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - }, - }, - ], - "return": { - "id": 16, + "type": { + "id": 7, "kind": "type_id", "loc": Int, "text": "Int", }, - "statements": [ - { - "expression": { - "base": 10, - "id": 24, - "kind": "number", - "loc": 123, - "value": 123n, - }, - "id": 25, - "kind": "statement_return", - "loc": return 123;, - }, - ], }, - "isAbstract": false, - "isGetter": false, - "isInline": false, - "isMutating": false, - "isOverride": false, - "isVirtual": false, - "methodId": null, - "name": "test_extends", - "origin": "user", - "params": [ - { - "loc": y: Int?, - "name": { - "id": 20, - "kind": "id", - "loc": y, - "text": "y", - }, - "type": { - "kind": "ref", - "name": "Int", - "optional": true, - }, + ], + "id": 10, + "kind": "trait", + "loc": trait Foo { + f: Int as int32; +}, + "name": { + "id": 5, + "kind": "id", + "loc": Foo, + "text": "Foo", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", }, - ], - "returns": { - "kind": "ref", - "name": "Int", - "optional": false, }, - "self": { + "as": "int32", + "ast": { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f, + "text": "f", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f: Int as int32, + "name": "f", + "type": { "kind": "ref", "name": "Int", "optional": false, }, }, - "test_extends_self" => { - "ast": { - "attributes": [ - { - "kind": "function_attribute", - "loc": extends, - "type": "extends", - }, - ], - "id": 38, - "kind": "function_def", - "loc": extends fun test_extends_self(self: Int?, y: Int): Int { - return 123; + ], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Foo", + "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, + }, + ], + "uid": 10576, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "as": { + "id": 15, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 16, + "initializer": null, + "kind": "field_decl", + "loc": f: Int as int32, + "name": { + "id": 13, + "kind": "id", + "loc": f, + "text": "f", + }, + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 17, + "kind": "contract", + "loc": contract SomeContract with Foo { + f: Int as int32; }, + "name": { + "id": 11, + "kind": "id", + "loc": SomeContract, + "text": "SomeContract", + }, + "traits": [ + { + "id": 12, + "kind": "id", + "loc": Foo, + "text": "Foo", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 15, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 16, + "initializer": null, + "kind": "field_decl", + "loc": f: Int as int32, "name": { - "id": 27, + "id": 13, "kind": "id", - "loc": test_extends_self, - "text": "test_extends_self", + "loc": f, + "text": "f", }, - "params": [ + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f: Int as int32, + "name": "f", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "functions": Map {}, + "header": null, + "init": { + "ast": { + "id": 19, + "kind": "contract_init", + "loc": contract SomeContract with Foo { + f: Int as int32; +}, + "params": [], + "statements": [], + }, + "params": [], + }, + "interfaces": [], + "kind": "contract", + "name": "SomeContract", + "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": 32, - "kind": "typed_parameter", - "loc": self: Int?, - "name": { - "id": 29, + "as": { + "id": 8, "kind": "id", - "loc": self, - "text": "self", - }, - "type": { - "id": 31, - "kind": "optional_type", - "loc": Int?, - "typeArg": { - "id": 30, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, + "loc": int32, + "text": "int32", }, - }, - { - "id": 35, - "kind": "typed_parameter", - "loc": y: Int, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f: Int as int32, "name": { - "id": 33, + "id": 6, "kind": "id", - "loc": y, - "text": "y", + "loc": f, + "text": "f", }, "type": { - "id": 34, + "id": 7, "kind": "type_id", "loc": Int, "text": "Int", }, }, ], - "return": { - "id": 28, - "kind": "type_id", - "loc": Int, - "text": "Int", + "id": 10, + "kind": "trait", + "loc": trait Foo { + f: Int as int32; +}, + "name": { + "id": 5, + "kind": "id", + "loc": Foo, + "text": "Foo", }, - "statements": [ - { - "expression": { - "base": 10, - "id": 36, - "kind": "number", - "loc": 123, - "value": 123n, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", }, - "id": 37, - "kind": "statement_return", - "loc": return 123;, }, - ], - }, - "isAbstract": false, - "isGetter": false, - "isInline": false, - "isMutating": false, - "isOverride": false, - "isVirtual": false, - "methodId": null, - "name": "test_extends_self", - "origin": "user", - "params": [ - { - "loc": y: Int, - "name": { - "id": 33, - "kind": "id", - "loc": y, - "text": "y", + "as": "int32", + "ast": { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f, + "text": "f", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, }, + "default": undefined, + "index": 0, + "loc": f: Int as int32, + "name": "f", "type": { "kind": "ref", "name": "Int", @@ -6456,18 +6768,80 @@ exports[`resolveDescriptors should resolve descriptors for fun-extends-opt-self }, }, ], - "returns": { - "kind": "ref", - "name": "Int", - "optional": false, - }, - "self": { - "kind": "ref", - "name": "Int", - "optional": true, - }, + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Foo", + "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, + }, + ], + "uid": 10576, }, - "test_mutates" => { + ], + "uid": 59799, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for contract-with-as-typed-field 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for fun-extends-opt-self 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 { + "test_extends" => { "ast": { "attributes": [ { @@ -6475,57 +6849,52 @@ exports[`resolveDescriptors should resolve descriptors for fun-extends-opt-self "loc": extends, "type": "extends", }, - { - "kind": "function_attribute", - "loc": mutates, - "type": "mutates", - }, ], - "id": 50, + "id": 26, "kind": "function_def", - "loc": extends mutates fun test_mutates(self: Int, y: Int?): Int { + "loc": extends fun test_extends(self: Int, y: Int?): Int { return 123; }, "name": { - "id": 39, + "id": 15, "kind": "id", - "loc": test_mutates, - "text": "test_mutates", + "loc": test_extends, + "text": "test_extends", }, "params": [ { - "id": 43, + "id": 19, "kind": "typed_parameter", "loc": self: Int, "name": { - "id": 41, + "id": 17, "kind": "id", "loc": self, "text": "self", }, "type": { - "id": 42, + "id": 18, "kind": "type_id", "loc": Int, "text": "Int", }, }, { - "id": 47, + "id": 23, "kind": "typed_parameter", "loc": y: Int?, "name": { - "id": 44, + "id": 20, "kind": "id", "loc": y, "text": "y", }, "type": { - "id": 46, + "id": 22, "kind": "optional_type", "loc": Int?, "typeArg": { - "id": 45, + "id": 21, "kind": "type_id", "loc": Int, "text": "Int", @@ -6534,7 +6903,7 @@ exports[`resolveDescriptors should resolve descriptors for fun-extends-opt-self }, ], "return": { - "id": 40, + "id": 16, "kind": "type_id", "loc": Int, "text": "Int", @@ -6543,12 +6912,12 @@ exports[`resolveDescriptors should resolve descriptors for fun-extends-opt-self { "expression": { "base": 10, - "id": 48, + "id": 24, "kind": "number", "loc": 123, "value": 123n, }, - "id": 49, + "id": 25, "kind": "statement_return", "loc": return 123;, }, @@ -6557,17 +6926,17 @@ exports[`resolveDescriptors should resolve descriptors for fun-extends-opt-self "isAbstract": false, "isGetter": false, "isInline": false, - "isMutating": true, + "isMutating": false, "isOverride": false, "isVirtual": false, "methodId": null, - "name": "test_mutates", + "name": "test_extends", "origin": "user", "params": [ { "loc": y: Int?, "name": { - "id": 44, + "id": 20, "kind": "id", "loc": y, "text": "y", @@ -6590,7 +6959,7 @@ exports[`resolveDescriptors should resolve descriptors for fun-extends-opt-self "optional": false, }, }, - "test_mutates_self" => { + "test_extends_self" => { "ast": { "attributes": [ { @@ -6598,40 +6967,35 @@ exports[`resolveDescriptors should resolve descriptors for fun-extends-opt-self "loc": extends, "type": "extends", }, - { - "kind": "function_attribute", - "loc": mutates, - "type": "mutates", - }, ], - "id": 62, + "id": 38, "kind": "function_def", - "loc": extends mutates fun test_mutates_self(self: Int?, y: Int): Int { + "loc": extends fun test_extends_self(self: Int?, y: Int): Int { return 123; }, "name": { - "id": 51, + "id": 27, "kind": "id", - "loc": test_mutates_self, - "text": "test_mutates_self", + "loc": test_extends_self, + "text": "test_extends_self", }, "params": [ { - "id": 56, + "id": 32, "kind": "typed_parameter", "loc": self: Int?, "name": { - "id": 53, + "id": 29, "kind": "id", "loc": self, "text": "self", }, "type": { - "id": 55, + "id": 31, "kind": "optional_type", "loc": Int?, "typeArg": { - "id": 54, + "id": 30, "kind": "type_id", "loc": Int, "text": "Int", @@ -6639,17 +7003,17 @@ exports[`resolveDescriptors should resolve descriptors for fun-extends-opt-self }, }, { - "id": 59, + "id": 35, "kind": "typed_parameter", "loc": y: Int, "name": { - "id": 57, + "id": 33, "kind": "id", "loc": y, "text": "y", }, "type": { - "id": 58, + "id": 34, "kind": "type_id", "loc": Int, "text": "Int", @@ -6657,7 +7021,7 @@ exports[`resolveDescriptors should resolve descriptors for fun-extends-opt-self }, ], "return": { - "id": 52, + "id": 28, "kind": "type_id", "loc": Int, "text": "Int", @@ -6666,12 +7030,12 @@ exports[`resolveDescriptors should resolve descriptors for fun-extends-opt-self { "expression": { "base": 10, - "id": 60, + "id": 36, "kind": "number", "loc": 123, "value": 123n, }, - "id": 61, + "id": 37, "kind": "statement_return", "loc": return 123;, }, @@ -6680,17 +7044,17 @@ exports[`resolveDescriptors should resolve descriptors for fun-extends-opt-self "isAbstract": false, "isGetter": false, "isInline": false, - "isMutating": true, + "isMutating": false, "isOverride": false, "isVirtual": false, "methodId": null, - "name": "test_mutates_self", + "name": "test_extends_self", "origin": "user", "params": [ { "loc": y: Int, "name": { - "id": 57, + "id": 33, "kind": "id", "loc": y, "text": "y", @@ -6713,7 +7077,7 @@ exports[`resolveDescriptors should resolve descriptors for fun-extends-opt-self "optional": true, }, }, - "test_mutates_self_opt" => { + "test_mutates" => { "ast": { "attributes": [ { @@ -6727,65 +7091,311 @@ exports[`resolveDescriptors should resolve descriptors for fun-extends-opt-self "type": "mutates", }, ], - "id": 75, + "id": 50, "kind": "function_def", - "loc": extends mutates fun test_mutates_self_opt(self: Int?, y: Int): Int? { - return null; + "loc": extends mutates fun test_mutates(self: Int, y: Int?): Int { + return 123; }, "name": { - "id": 63, + "id": 39, "kind": "id", - "loc": test_mutates_self_opt, - "text": "test_mutates_self_opt", + "loc": test_mutates, + "text": "test_mutates", }, "params": [ { - "id": 69, + "id": 43, "kind": "typed_parameter", - "loc": self: Int?, + "loc": self: Int, "name": { - "id": 66, + "id": 41, "kind": "id", "loc": self, "text": "self", }, "type": { - "id": 68, - "kind": "optional_type", - "loc": Int?, - "typeArg": { - "id": 67, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, + "id": 42, + "kind": "type_id", + "loc": Int, + "text": "Int", }, }, { - "id": 72, + "id": 47, "kind": "typed_parameter", - "loc": y: Int, + "loc": y: Int?, "name": { - "id": 70, + "id": 44, "kind": "id", "loc": y, "text": "y", }, "type": { - "id": 71, - "kind": "type_id", - "loc": Int, - "text": "Int", + "id": 46, + "kind": "optional_type", + "loc": Int?, + "typeArg": { + "id": 45, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, }, }, ], "return": { - "id": 65, - "kind": "optional_type", - "loc": Int?, - "typeArg": { - "id": 64, - "kind": "type_id", + "id": 40, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + "statements": [ + { + "expression": { + "base": 10, + "id": 48, + "kind": "number", + "loc": 123, + "value": 123n, + }, + "id": 49, + "kind": "statement_return", + "loc": return 123;, + }, + ], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "test_mutates", + "origin": "user", + "params": [ + { + "loc": y: Int?, + "name": { + "id": 44, + "kind": "id", + "loc": y, + "text": "y", + }, + "type": { + "kind": "ref", + "name": "Int", + "optional": true, + }, + }, + ], + "returns": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "self": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + "test_mutates_self" => { + "ast": { + "attributes": [ + { + "kind": "function_attribute", + "loc": extends, + "type": "extends", + }, + { + "kind": "function_attribute", + "loc": mutates, + "type": "mutates", + }, + ], + "id": 62, + "kind": "function_def", + "loc": extends mutates fun test_mutates_self(self: Int?, y: Int): Int { + return 123; +}, + "name": { + "id": 51, + "kind": "id", + "loc": test_mutates_self, + "text": "test_mutates_self", + }, + "params": [ + { + "id": 56, + "kind": "typed_parameter", + "loc": self: Int?, + "name": { + "id": 53, + "kind": "id", + "loc": self, + "text": "self", + }, + "type": { + "id": 55, + "kind": "optional_type", + "loc": Int?, + "typeArg": { + "id": 54, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + }, + { + "id": 59, + "kind": "typed_parameter", + "loc": y: Int, + "name": { + "id": 57, + "kind": "id", + "loc": y, + "text": "y", + }, + "type": { + "id": 58, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "return": { + "id": 52, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + "statements": [ + { + "expression": { + "base": 10, + "id": 60, + "kind": "number", + "loc": 123, + "value": 123n, + }, + "id": 61, + "kind": "statement_return", + "loc": return 123;, + }, + ], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "test_mutates_self", + "origin": "user", + "params": [ + { + "loc": y: Int, + "name": { + "id": 57, + "kind": "id", + "loc": y, + "text": "y", + }, + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "returns": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + "self": { + "kind": "ref", + "name": "Int", + "optional": true, + }, + }, + "test_mutates_self_opt" => { + "ast": { + "attributes": [ + { + "kind": "function_attribute", + "loc": extends, + "type": "extends", + }, + { + "kind": "function_attribute", + "loc": mutates, + "type": "mutates", + }, + ], + "id": 75, + "kind": "function_def", + "loc": extends mutates fun test_mutates_self_opt(self: Int?, y: Int): Int? { + return null; +}, + "name": { + "id": 63, + "kind": "id", + "loc": test_mutates_self_opt, + "text": "test_mutates_self_opt", + }, + "params": [ + { + "id": 69, + "kind": "typed_parameter", + "loc": self: Int?, + "name": { + "id": 66, + "kind": "id", + "loc": self, + "text": "self", + }, + "type": { + "id": 68, + "kind": "optional_type", + "loc": Int?, + "typeArg": { + "id": 67, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + }, + { + "id": 72, + "kind": "typed_parameter", + "loc": y: Int, + "name": { + "id": 70, + "kind": "id", + "loc": y, + "text": "y", + }, + "type": { + "id": 71, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "return": { + "id": 65, + "kind": "optional_type", + "loc": Int?, + "typeArg": { + "id": 64, + "kind": "type_id", "loc": Int, "text": "Int", }, @@ -14830,37 +15440,3921 @@ exports[`resolveDescriptors should resolve descriptors for trait-base 1`] = ` "loc": trait BaseTrait { }, - "name": { - "id": 5, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", + "name": { + "id": 5, + "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, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for trait-base 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for trait-foreach 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": [ + { + "as": null, + "id": 10, + "initializer": null, + "kind": "field_decl", + "loc": m: map, + "name": { + "id": 6, + "kind": "id", + "loc": m, + "text": "m", + }, + "type": { + "id": 9, + "keyStorageType": null, + "keyType": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + "kind": "map_type", + "loc": map, + "valueStorageType": null, + "valueType": { + "id": 8, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + }, + { + "attributes": [], + "id": 18, + "kind": "function_def", + "loc": fun test() { foreach(_, _ in self.m) { } }, + "name": { + "id": 11, + "kind": "id", + "loc": test, + "text": "test", + }, + "params": [], + "return": null, + "statements": [ + { + "id": 17, + "keyName": { + "id": 12, + "kind": "id", + "loc": _, + "text": "_", + }, + "kind": "statement_foreach", + "loc": foreach(_, _ in self.m) { }, + "map": { + "aggregate": { + "id": 14, + "kind": "id", + "loc": self, + "text": "self", + }, + "field": { + "id": 15, + "kind": "id", + "loc": m, + "text": "m", + }, + "id": 16, + "kind": "field_access", + "loc": self.m, + }, + "statements": [], + "valueName": { + "id": 13, + "kind": "id", + "loc": _, + "text": "_", + }, + }, + ], + }, + ], + "id": 19, + "kind": "trait", + "loc": trait TraitWithForeach { + m: map; + + fun test() { foreach(_, _ in self.m) { } } +}, + "name": { + "id": 5, + "kind": "id", + "loc": TraitWithForeach, + "text": "TraitWithForeach", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "m", + "type": { + "key": "int", + "keyFormat": undefined, + "kind": "dict", + "value": "int", + "valueFormat": undefined, + }, + }, + "as": null, + "ast": { + "as": null, + "id": 10, + "initializer": null, + "kind": "field_decl", + "loc": m: map, + "name": { + "id": 6, + "kind": "id", + "loc": m, + "text": "m", + }, + "type": { + "id": 9, + "keyStorageType": null, + "keyType": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + "kind": "map_type", + "loc": map, + "valueStorageType": null, + "valueType": { + "id": 8, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + }, + "default": undefined, + "index": 0, + "loc": m: map, + "name": "m", + "type": { + "key": "Int", + "keyAs": null, + "kind": "map", + "value": "Int", + "valueAs": null, + }, + }, + ], + "functions": Map { + "test" => { + "ast": { + "attributes": [], + "id": 18, + "kind": "function_def", + "loc": fun test() { foreach(_, _ in self.m) { } }, + "name": { + "id": 11, + "kind": "id", + "loc": test, + "text": "test", + }, + "params": [], + "return": null, + "statements": [ + { + "id": 17, + "keyName": { + "id": 12, + "kind": "id", + "loc": _, + "text": "_", + }, + "kind": "statement_foreach", + "loc": foreach(_, _ in self.m) { }, + "map": { + "aggregate": { + "id": 14, + "kind": "id", + "loc": self, + "text": "self", + }, + "field": { + "id": 15, + "kind": "id", + "loc": m, + "text": "m", + }, + "id": 16, + "kind": "field_access", + "loc": self.m, + }, + "statements": [], + "valueName": { + "id": 13, + "kind": "id", + "loc": _, + "text": "_", + }, + }, + ], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "test", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "TraitWithForeach", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "TraitWithForeach", + "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, + }, + ], + "uid": 20892, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "as": null, + "id": 26, + "initializer": null, + "kind": "field_decl", + "loc": m: map, + "name": { + "id": 22, + "kind": "id", + "loc": m, + "text": "m", + }, + "type": { + "id": 25, + "keyStorageType": null, + "keyType": { + "id": 23, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + "kind": "map_type", + "loc": map, + "valueStorageType": null, + "valueType": { + "id": 24, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + }, + ], + "id": 27, + "kind": "contract", + "loc": contract Test with TraitWithForeach { + m: map; +}, + "name": { + "id": 20, + "kind": "id", + "loc": Test, + "text": "Test", + }, + "traits": [ + { + "id": 21, + "kind": "id", + "loc": TraitWithForeach, + "text": "TraitWithForeach", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "m", + "type": { + "key": "int", + "keyFormat": undefined, + "kind": "dict", + "value": "int", + "valueFormat": undefined, + }, + }, + "as": null, + "ast": { + "as": null, + "id": 26, + "initializer": null, + "kind": "field_decl", + "loc": m: map, + "name": { + "id": 22, + "kind": "id", + "loc": m, + "text": "m", + }, + "type": { + "id": 25, + "keyStorageType": null, + "keyType": { + "id": 23, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + "kind": "map_type", + "loc": map, + "valueStorageType": null, + "valueType": { + "id": 24, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + }, + "default": undefined, + "index": 0, + "loc": m: map, + "name": "m", + "type": { + "key": "Int", + "keyAs": null, + "kind": "map", + "value": "Int", + "valueAs": null, + }, + }, + ], + "functions": Map { + "test" => { + "ast": { + "attributes": [], + "id": 33, + "kind": "function_def", + "loc": fun test() { foreach(_, _ in self.m) { } }, + "name": { + "id": 11, + "kind": "id", + "loc": test, + "text": "test", + }, + "params": [], + "return": null, + "statements": [ + { + "id": 32, + "keyName": { + "id": 12, + "kind": "id", + "loc": _, + "text": "_", + }, + "kind": "statement_foreach", + "loc": foreach(_, _ in self.m) { }, + "map": { + "aggregate": { + "id": 30, + "kind": "id", + "loc": self, + "text": "self", + }, + "field": { + "id": 15, + "kind": "id", + "loc": m, + "text": "m", + }, + "id": 31, + "kind": "field_access", + "loc": self.m, + }, + "statements": [], + "valueName": { + "id": 13, + "kind": "id", + "loc": _, + "text": "_", + }, + }, + ], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "test", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "Test", + "optional": false, + }, + }, + }, + "header": null, + "init": { + "ast": { + "id": 29, + "kind": "contract_init", + "loc": contract Test with TraitWithForeach { + m: map; +}, + "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": [ + { + "as": null, + "id": 10, + "initializer": null, + "kind": "field_decl", + "loc": m: map, + "name": { + "id": 6, + "kind": "id", + "loc": m, + "text": "m", + }, + "type": { + "id": 9, + "keyStorageType": null, + "keyType": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + "kind": "map_type", + "loc": map, + "valueStorageType": null, + "valueType": { + "id": 8, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + }, + { + "attributes": [], + "id": 18, + "kind": "function_def", + "loc": fun test() { foreach(_, _ in self.m) { } }, + "name": { + "id": 11, + "kind": "id", + "loc": test, + "text": "test", + }, + "params": [], + "return": null, + "statements": [ + { + "id": 17, + "keyName": { + "id": 12, + "kind": "id", + "loc": _, + "text": "_", + }, + "kind": "statement_foreach", + "loc": foreach(_, _ in self.m) { }, + "map": { + "aggregate": { + "id": 14, + "kind": "id", + "loc": self, + "text": "self", + }, + "field": { + "id": 15, + "kind": "id", + "loc": m, + "text": "m", + }, + "id": 16, + "kind": "field_access", + "loc": self.m, + }, + "statements": [], + "valueName": { + "id": 13, + "kind": "id", + "loc": _, + "text": "_", + }, + }, + ], + }, + ], + "id": 19, + "kind": "trait", + "loc": trait TraitWithForeach { + m: map; + + fun test() { foreach(_, _ in self.m) { } } +}, + "name": { + "id": 5, + "kind": "id", + "loc": TraitWithForeach, + "text": "TraitWithForeach", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "m", + "type": { + "key": "int", + "keyFormat": undefined, + "kind": "dict", + "value": "int", + "valueFormat": undefined, + }, + }, + "as": null, + "ast": { + "as": null, + "id": 10, + "initializer": null, + "kind": "field_decl", + "loc": m: map, + "name": { + "id": 6, + "kind": "id", + "loc": m, + "text": "m", + }, + "type": { + "id": 9, + "keyStorageType": null, + "keyType": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + "kind": "map_type", + "loc": map, + "valueStorageType": null, + "valueType": { + "id": 8, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + }, + "default": undefined, + "index": 0, + "loc": m: map, + "name": "m", + "type": { + "key": "Int", + "keyAs": null, + "kind": "map", + "value": "Int", + "valueAs": null, + }, + }, + ], + "functions": Map { + "test" => { + "ast": { + "attributes": [], + "id": 18, + "kind": "function_def", + "loc": fun test() { foreach(_, _ in self.m) { } }, + "name": { + "id": 11, + "kind": "id", + "loc": test, + "text": "test", + }, + "params": [], + "return": null, + "statements": [ + { + "id": 17, + "keyName": { + "id": 12, + "kind": "id", + "loc": _, + "text": "_", + }, + "kind": "statement_foreach", + "loc": foreach(_, _ in self.m) { }, + "map": { + "aggregate": { + "id": 14, + "kind": "id", + "loc": self, + "text": "self", + }, + "field": { + "id": 15, + "kind": "id", + "loc": m, + "text": "m", + }, + "id": 16, + "kind": "field_access", + "loc": self.m, + }, + "statements": [], + "valueName": { + "id": 13, + "kind": "id", + "loc": _, + "text": "_", + }, + }, + ], + }, + "isAbstract": false, + "isGetter": false, + "isInline": false, + "isMutating": true, + "isOverride": false, + "isVirtual": false, + "methodId": null, + "name": "test", + "origin": "user", + "params": [], + "returns": { + "kind": "void", + }, + "self": { + "kind": "ref", + "name": "TraitWithForeach", + "optional": false, + }, + }, + }, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "TraitWithForeach", + "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, + }, + ], + "uid": 20892, + }, + ], + "uid": 44104, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for trait-foreach 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for trait-int-field-with-inheritance-with-as-typed-int257-field 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": [ + { + "as": null, + "id": 8, + "initializer": null, + "kind": "field_decl", + "loc": f: Int, + "name": { + "id": 6, + "kind": "id", + "loc": f, + "text": "f", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 9, + "kind": "trait", + "loc": trait Foo { + f: Int; +}, + "name": { + "id": 5, + "kind": "id", + "loc": Foo, + "text": "Foo", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f", + "type": { + "format": 257, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": null, + "ast": { + "as": null, + "id": 8, + "initializer": null, + "kind": "field_decl", + "loc": f: Int, + "name": { + "id": 6, + "kind": "id", + "loc": f, + "text": "f", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f: Int, + "name": "f", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Foo", + "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, + }, + ], + "uid": 10576, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "as": { + "id": 14, + "kind": "id", + "loc": int257, + "text": "int257", + }, + "id": 15, + "initializer": null, + "kind": "field_decl", + "loc": f: Int as int257, + "name": { + "id": 12, + "kind": "id", + "loc": f, + "text": "f", + }, + "type": { + "id": 13, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 16, + "kind": "trait", + "loc": trait SomeTrait with Foo { + f: Int as int257; +}, + "name": { + "id": 10, + "kind": "id", + "loc": SomeTrait, + "text": "SomeTrait", + }, + "traits": [ + { + "id": 11, + "kind": "id", + "loc": Foo, + "text": "Foo", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f", + "type": { + "format": 257, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int257", + "ast": { + "as": { + "id": 14, + "kind": "id", + "loc": int257, + "text": "int257", + }, + "id": 15, + "initializer": null, + "kind": "field_decl", + "loc": f: Int as int257, + "name": { + "id": 12, + "kind": "id", + "loc": f, + "text": "f", + }, + "type": { + "id": 13, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f: Int as int257, + "name": "f", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "SomeTrait", + "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": [ + { + "as": null, + "id": 8, + "initializer": null, + "kind": "field_decl", + "loc": f: Int, + "name": { + "id": 6, + "kind": "id", + "loc": f, + "text": "f", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 9, + "kind": "trait", + "loc": trait Foo { + f: Int; +}, + "name": { + "id": 5, + "kind": "id", + "loc": Foo, + "text": "Foo", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f", + "type": { + "format": 257, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": null, + "ast": { + "as": null, + "id": 8, + "initializer": null, + "kind": "field_decl", + "loc": f: Int, + "name": { + "id": 6, + "kind": "id", + "loc": f, + "text": "f", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f: Int, + "name": "f", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Foo", + "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, + }, + ], + "uid": 10576, + }, + ], + "uid": 8387, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for trait-int-field-with-inheritance-with-as-typed-int257-field 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for trait-with-as-typed-field 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": [ + { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f, + "text": "f", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait Foo { + f: Int as int32; +}, + "name": { + "id": 5, + "kind": "id", + "loc": Foo, + "text": "Foo", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f, + "text": "f", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f: Int as int32, + "name": "f", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Foo", + "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, + }, + ], + "uid": 10576, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "as": { + "id": 15, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 16, + "initializer": null, + "kind": "field_decl", + "loc": f: Int as int32, + "name": { + "id": 13, + "kind": "id", + "loc": f, + "text": "f", + }, + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 17, + "kind": "trait", + "loc": trait SomeTrait with Foo { + f: Int as int32; +}, + "name": { + "id": 11, + "kind": "id", + "loc": SomeTrait, + "text": "SomeTrait", + }, + "traits": [ + { + "id": 12, + "kind": "id", + "loc": Foo, + "text": "Foo", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 15, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 16, + "initializer": null, + "kind": "field_decl", + "loc": f: Int as int32, + "name": { + "id": 13, + "kind": "id", + "loc": f, + "text": "f", + }, + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f: Int as int32, + "name": "f", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "SomeTrait", + "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": [ + { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f, + "text": "f", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait Foo { + f: Int as int32; +}, + "name": { + "id": 5, + "kind": "id", + "loc": Foo, + "text": "Foo", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f, + "text": "f", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f: Int as int32, + "name": "f", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "Foo", + "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, + }, + ], + "uid": 10576, + }, + ], + "uid": 8387, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for trait-with-as-typed-field 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for trait-with-as-typed-field-in-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": [ + { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait T { + f1: Int as int32; +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f1", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f1: Int as int32, + "name": "f1", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 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, + }, + ], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "as": { + "id": 15, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 16, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 13, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + { + "as": { + "id": 19, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 20, + "initializer": null, + "kind": "field_decl", + "loc": f2: Int as int32, + "name": { + "id": 17, + "kind": "id", + "loc": f2, + "text": "f2", + }, + "type": { + "id": 18, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 21, + "kind": "trait", + "loc": trait T2 with T { + f1: Int as int32; + f2: Int as int32; +}, + "name": { + "id": 11, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 12, + "kind": "id", + "loc": T, + "text": "T", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f1", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 15, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 16, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 13, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f1: Int as int32, + "name": "f1", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + { + "abi": { + "name": "f2", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 19, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 20, + "initializer": null, + "kind": "field_decl", + "loc": f2: Int as int32, + "name": { + "id": 17, + "kind": "id", + "loc": f2, + "text": "f2", + }, + "type": { + "id": 18, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 1, + "loc": f2: Int as int32, + "name": "f2", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "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": 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": [ + { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait T { + f1: Int as int32; +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f1", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f1: Int as int32, + "name": "f1", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 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, + }, + ], + "uid": 6769, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "as": { + "id": 26, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 27, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 24, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 25, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + { + "as": { + "id": 30, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 31, + "initializer": null, + "kind": "field_decl", + "loc": f3: Int as int32, + "name": { + "id": 28, + "kind": "id", + "loc": f3, + "text": "f3", + }, + "type": { + "id": 29, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 32, + "kind": "trait", + "loc": trait T3 with T { + f1: Int as int32; + f3: Int as int32; +}, + "name": { + "id": 22, + "kind": "id", + "loc": T3, + "text": "T3", + }, + "traits": [ + { + "id": 23, + "kind": "id", + "loc": T, + "text": "T", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f1", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 26, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 27, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 24, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 25, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f1: Int as int32, + "name": "f1", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + { + "abi": { + "name": "f3", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 30, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 31, + "initializer": null, + "kind": "field_decl", + "loc": f3: Int as int32, + "name": { + "id": 28, + "kind": "id", + "loc": f3, + "text": "f3", + }, + "type": { + "id": 29, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 1, + "loc": f3: Int as int32, + "name": "f3", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T3", + "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": [ + { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait T { + f1: Int as int32; +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f1", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f1: Int as int32, + "name": "f1", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 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, + }, + ], + "uid": 6769, + }, + ], + "uid": 50251, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "as": { + "id": 38, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 39, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 36, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 37, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + { + "as": { + "id": 42, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 43, + "initializer": null, + "kind": "field_decl", + "loc": f2: Int as int32, + "name": { + "id": 40, + "kind": "id", + "loc": f2, + "text": "f2", + }, + "type": { + "id": 41, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + { + "as": { + "id": 46, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 47, + "initializer": null, + "kind": "field_decl", + "loc": f3: Int as int32, + "name": { + "id": 44, + "kind": "id", + "loc": f3, + "text": "f3", + }, + "type": { + "id": 45, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 48, + "kind": "trait", + "loc": trait SomeTrait with T2, T3 { + f1: Int as int32; + f2: Int as int32; + f3: Int as int32; +}, + "name": { + "id": 33, + "kind": "id", + "loc": SomeTrait, + "text": "SomeTrait", + }, + "traits": [ + { + "id": 34, + "kind": "id", + "loc": T2, + "text": "T2", + }, + { + "id": 35, + "kind": "id", + "loc": T3, + "text": "T3", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f1", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 38, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 39, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 36, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 37, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f1: Int as int32, + "name": "f1", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + { + "abi": { + "name": "f2", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 42, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 43, + "initializer": null, + "kind": "field_decl", + "loc": f2: Int as int32, + "name": { + "id": 40, + "kind": "id", + "loc": f2, + "text": "f2", + }, + "type": { + "id": 41, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 1, + "loc": f2: Int as int32, + "name": "f2", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + { + "abi": { + "name": "f3", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 46, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 47, + "initializer": null, + "kind": "field_decl", + "loc": f3: Int as int32, + "name": { + "id": 44, + "kind": "id", + "loc": f3, + "text": "f3", + }, + "type": { + "id": 45, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 2, + "loc": f3: Int as int32, + "name": "f3", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "SomeTrait", + "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": [ + { + "as": { + "id": 15, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 16, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 13, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + { + "as": { + "id": 19, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 20, + "initializer": null, + "kind": "field_decl", + "loc": f2: Int as int32, + "name": { + "id": 17, + "kind": "id", + "loc": f2, + "text": "f2", + }, + "type": { + "id": 18, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 21, + "kind": "trait", + "loc": trait T2 with T { + f1: Int as int32; + f2: Int as int32; +}, + "name": { + "id": 11, + "kind": "id", + "loc": T2, + "text": "T2", + }, + "traits": [ + { + "id": 12, + "kind": "id", + "loc": T, + "text": "T", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f1", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 15, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 16, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 13, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f1: Int as int32, + "name": "f1", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + { + "abi": { + "name": "f2", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 19, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 20, + "initializer": null, + "kind": "field_decl", + "loc": f2: Int as int32, + "name": { + "id": 17, + "kind": "id", + "loc": f2, + "text": "f2", + }, + "type": { + "id": 18, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 1, + "loc": f2: Int as int32, + "name": "f2", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "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": 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": [ + { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait T { + f1: Int as int32; +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f1", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f1: Int as int32, + "name": "f1", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 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, + }, + ], + "uid": 6769, + }, + ], + "uid": 54378, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait T { + f1: Int as int32; +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f1", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f1: Int as int32, + "name": "f1", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 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, + }, + ], + "uid": 6769, + }, + { + "ast": { + "attributes": [], + "declarations": [ + { + "as": { + "id": 26, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 27, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 24, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 25, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + { + "as": { + "id": 30, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 31, + "initializer": null, + "kind": "field_decl", + "loc": f3: Int as int32, + "name": { + "id": 28, + "kind": "id", + "loc": f3, + "text": "f3", + }, + "type": { + "id": 29, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 32, + "kind": "trait", + "loc": trait T3 with T { + f1: Int as int32; + f3: Int as int32; +}, + "name": { + "id": 22, + "kind": "id", + "loc": T3, + "text": "T3", + }, + "traits": [ + { + "id": 23, + "kind": "id", + "loc": T, + "text": "T", + }, + ], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f1", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 26, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 27, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 24, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 25, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f1: Int as int32, + "name": "f1", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + { + "abi": { + "name": "f3", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 30, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 31, + "initializer": null, + "kind": "field_decl", + "loc": f3: Int as int32, + "name": { + "id": 28, + "kind": "id", + "loc": f3, + "text": "f3", + }, + "type": { + "id": 29, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 1, + "loc": f3: Int as int32, + "name": "f3", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T3", + "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": [ + { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 10, + "kind": "trait", + "loc": trait T { + f1: Int as int32; +}, + "name": { + "id": 5, + "kind": "id", + "loc": T, + "text": "T", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "f1", + "type": { + "format": 32, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": "int32", + "ast": { + "as": { + "id": 8, + "kind": "id", + "loc": int32, + "text": "int32", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f1: Int as int32, + "name": { + "id": 6, + "kind": "id", + "loc": f1, + "text": "f1", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": f1: Int as int32, + "name": "f1", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, + }, + ], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "T", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [ + { + "ast": { + "attributes": [], + "declarations": [], + "id": 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, + }, + ], + "uid": 6769, + }, + ], + "uid": 50251, }, - "traits": [], - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "trait", - "name": "BaseTrait", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 1020, + ], + "uid": 8387, }, ] `; -exports[`resolveDescriptors should resolve descriptors for trait-base 2`] = `[]`; +exports[`resolveDescriptors should resolve descriptors for trait-with-as-typed-field-in-diamond-inheritance 2`] = `[]`; -exports[`resolveDescriptors should resolve descriptors for trait-foreach 1`] = ` +exports[`resolveDescriptors should resolve descriptors for trait-with-as-typed-int257-field-with-inheritance-without-typed-field 1`] = ` [ { "ast": { @@ -14897,7 +19391,7 @@ exports[`resolveDescriptors should resolve descriptors for trait-foreach 1`] = ` "declarations": [], "id": 4, "kind": "trait", - "loc": trait BaseTrait { }, + "loc": trait BaseTrait {}, "name": { "id": 3, "kind": "id", @@ -14928,101 +19422,40 @@ exports[`resolveDescriptors should resolve descriptors for trait-foreach 1`] = ` "attributes": [], "declarations": [ { - "as": null, - "id": 10, + "as": { + "id": 8, + "kind": "id", + "loc": int257, + "text": "int257", + }, + "id": 9, "initializer": null, "kind": "field_decl", - "loc": m: map, + "loc": f: Int as int257, "name": { "id": 6, "kind": "id", - "loc": m, - "text": "m", + "loc": f, + "text": "f", }, "type": { - "id": 9, - "keyStorageType": null, - "keyType": { - "id": 7, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - "kind": "map_type", - "loc": map, - "valueStorageType": null, - "valueType": { - "id": 8, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - }, - }, - { - "attributes": [], - "id": 18, - "kind": "function_def", - "loc": fun test() { foreach(_, _ in self.m) { } }, - "name": { - "id": 11, - "kind": "id", - "loc": test, - "text": "test", + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", }, - "params": [], - "return": null, - "statements": [ - { - "id": 17, - "keyName": { - "id": 12, - "kind": "id", - "loc": _, - "text": "_", - }, - "kind": "statement_foreach", - "loc": foreach(_, _ in self.m) { }, - "map": { - "aggregate": { - "id": 14, - "kind": "id", - "loc": self, - "text": "self", - }, - "field": { - "id": 15, - "kind": "id", - "loc": m, - "text": "m", - }, - "id": 16, - "kind": "field_access", - "loc": self.m, - }, - "statements": [], - "valueName": { - "id": 13, - "kind": "id", - "loc": _, - "text": "_", - }, - }, - ], }, ], - "id": 19, + "id": 10, "kind": "trait", - "loc": trait TraitWithForeach { - m: map; - - fun test() { foreach(_, _ in self.m) { } } + "loc": trait Foo { + f: Int as int257; }, "name": { "id": 5, "kind": "id", - "loc": TraitWithForeach, - "text": "TraitWithForeach", + "loc": Foo, + "text": "Foo", }, "traits": [], }, @@ -15031,139 +19464,56 @@ exports[`resolveDescriptors should resolve descriptors for trait-foreach 1`] = ` "fields": [ { "abi": { - "name": "m", - "type": { - "key": "int", - "keyFormat": undefined, - "kind": "dict", - "value": "int", - "valueFormat": undefined, - }, - }, - "as": null, - "ast": { - "as": null, - "id": 10, - "initializer": null, - "kind": "field_decl", - "loc": m: map, - "name": { - "id": 6, - "kind": "id", - "loc": m, - "text": "m", - }, + "name": "f", "type": { - "id": 9, - "keyStorageType": null, - "keyType": { - "id": 7, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - "kind": "map_type", - "loc": map, - "valueStorageType": null, - "valueType": { - "id": 8, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - }, - }, - "default": undefined, - "index": 0, - "loc": m: map, - "name": "m", - "type": { - "key": "Int", - "keyAs": null, - "kind": "map", - "value": "Int", - "valueAs": null, + "format": 257, + "kind": "simple", + "optional": false, + "type": "int", + }, }, - }, - ], - "functions": Map { - "test" => { + "as": "int257", "ast": { - "attributes": [], - "id": 18, - "kind": "function_def", - "loc": fun test() { foreach(_, _ in self.m) { } }, + "as": { + "id": 8, + "kind": "id", + "loc": int257, + "text": "int257", + }, + "id": 9, + "initializer": null, + "kind": "field_decl", + "loc": f: Int as int257, "name": { - "id": 11, + "id": 6, "kind": "id", - "loc": test, - "text": "test", + "loc": f, + "text": "f", + }, + "type": { + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", }, - "params": [], - "return": null, - "statements": [ - { - "id": 17, - "keyName": { - "id": 12, - "kind": "id", - "loc": _, - "text": "_", - }, - "kind": "statement_foreach", - "loc": foreach(_, _ in self.m) { }, - "map": { - "aggregate": { - "id": 14, - "kind": "id", - "loc": self, - "text": "self", - }, - "field": { - "id": 15, - "kind": "id", - "loc": m, - "text": "m", - }, - "id": 16, - "kind": "field_access", - "loc": self.m, - }, - "statements": [], - "valueName": { - "id": 13, - "kind": "id", - "loc": _, - "text": "_", - }, - }, - ], - }, - "isAbstract": false, - "isGetter": false, - "isInline": false, - "isMutating": true, - "isOverride": false, - "isVirtual": false, - "methodId": null, - "name": "test", - "origin": "user", - "params": [], - "returns": { - "kind": "void", }, - "self": { + "default": undefined, + "index": 0, + "loc": f: Int as int257, + "name": "f", + "type": { "kind": "ref", - "name": "TraitWithForeach", + "name": "Int", "optional": false, }, }, - }, + ], + "functions": Map {}, "header": null, "init": null, "interfaces": [], "kind": "trait", - "name": "TraitWithForeach", + "name": "Foo", "origin": "user", "partialFieldCount": 0, "receivers": [], @@ -15176,7 +19526,7 @@ exports[`resolveDescriptors should resolve descriptors for trait-foreach 1`] = ` "declarations": [], "id": 4, "kind": "trait", - "loc": trait BaseTrait { }, + "loc": trait BaseTrait {}, "name": { "id": 3, "kind": "id", @@ -15203,7 +19553,7 @@ exports[`resolveDescriptors should resolve descriptors for trait-foreach 1`] = ` "uid": 1020, }, ], - "uid": 20892, + "uid": 10576, }, { "ast": { @@ -15211,54 +19561,41 @@ exports[`resolveDescriptors should resolve descriptors for trait-foreach 1`] = ` "declarations": [ { "as": null, - "id": 26, + "id": 15, "initializer": null, "kind": "field_decl", - "loc": m: map, + "loc": f: Int, "name": { - "id": 22, + "id": 13, "kind": "id", - "loc": m, - "text": "m", + "loc": f, + "text": "f", }, "type": { - "id": 25, - "keyStorageType": null, - "keyType": { - "id": 23, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - "kind": "map_type", - "loc": map, - "valueStorageType": null, - "valueType": { - "id": 24, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", }, }, ], - "id": 27, - "kind": "contract", - "loc": contract Test with TraitWithForeach { - m: map; + "id": 16, + "kind": "trait", + "loc": trait SomeTrait with Foo { + f: Int; }, "name": { - "id": 20, + "id": 11, "kind": "id", - "loc": Test, - "text": "Test", + "loc": SomeTrait, + "text": "SomeTrait", }, "traits": [ { - "id": 21, + "id": 12, "kind": "id", - "loc": TraitWithForeach, - "text": "TraitWithForeach", + "loc": Foo, + "text": "Foo", }, ], }, @@ -15267,150 +19604,51 @@ exports[`resolveDescriptors should resolve descriptors for trait-foreach 1`] = ` "fields": [ { "abi": { - "name": "m", + "name": "f", "type": { - "key": "int", - "keyFormat": undefined, - "kind": "dict", - "value": "int", - "valueFormat": undefined, + "format": 257, + "kind": "simple", + "optional": false, + "type": "int", }, }, "as": null, "ast": { - "as": null, - "id": 26, - "initializer": null, - "kind": "field_decl", - "loc": m: map, - "name": { - "id": 22, - "kind": "id", - "loc": m, - "text": "m", - }, - "type": { - "id": 25, - "keyStorageType": null, - "keyType": { - "id": 23, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - "kind": "map_type", - "loc": map, - "valueStorageType": null, - "valueType": { - "id": 24, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - }, - }, - "default": undefined, - "index": 0, - "loc": m: map, - "name": "m", - "type": { - "key": "Int", - "keyAs": null, - "kind": "map", - "value": "Int", - "valueAs": null, - }, - }, - ], - "functions": Map { - "test" => { - "ast": { - "attributes": [], - "id": 33, - "kind": "function_def", - "loc": fun test() { foreach(_, _ in self.m) { } }, - "name": { - "id": 11, - "kind": "id", - "loc": test, - "text": "test", - }, - "params": [], - "return": null, - "statements": [ - { - "id": 32, - "keyName": { - "id": 12, - "kind": "id", - "loc": _, - "text": "_", - }, - "kind": "statement_foreach", - "loc": foreach(_, _ in self.m) { }, - "map": { - "aggregate": { - "id": 30, - "kind": "id", - "loc": self, - "text": "self", - }, - "field": { - "id": 15, - "kind": "id", - "loc": m, - "text": "m", - }, - "id": 31, - "kind": "field_access", - "loc": self.m, - }, - "statements": [], - "valueName": { - "id": 13, - "kind": "id", - "loc": _, - "text": "_", - }, - }, - ], - }, - "isAbstract": false, - "isGetter": false, - "isInline": false, - "isMutating": true, - "isOverride": false, - "isVirtual": false, - "methodId": null, - "name": "test", - "origin": "user", - "params": [], - "returns": { - "kind": "void", + "as": null, + "id": 15, + "initializer": null, + "kind": "field_decl", + "loc": f: Int, + "name": { + "id": 13, + "kind": "id", + "loc": f, + "text": "f", + }, + "type": { + "id": 14, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, }, - "self": { + "default": undefined, + "index": 0, + "loc": f: Int, + "name": "f", + "type": { "kind": "ref", - "name": "Test", + "name": "Int", "optional": false, }, }, - }, + ], + "functions": Map {}, "header": null, - "init": { - "ast": { - "id": 29, - "kind": "contract_init", - "loc": contract Test with TraitWithForeach { - m: map; -}, - "params": [], - "statements": [], - }, - "params": [], - }, + "init": null, "interfaces": [], - "kind": "contract", - "name": "Test", + "kind": "trait", + "name": "SomeTrait", "origin": "user", "partialFieldCount": 0, "receivers": [], @@ -15423,7 +19661,7 @@ exports[`resolveDescriptors should resolve descriptors for trait-foreach 1`] = ` "declarations": [], "id": 4, "kind": "trait", - "loc": trait BaseTrait { }, + "loc": trait BaseTrait {}, "name": { "id": 3, "kind": "id", @@ -15454,101 +19692,40 @@ exports[`resolveDescriptors should resolve descriptors for trait-foreach 1`] = ` "attributes": [], "declarations": [ { - "as": null, - "id": 10, + "as": { + "id": 8, + "kind": "id", + "loc": int257, + "text": "int257", + }, + "id": 9, "initializer": null, "kind": "field_decl", - "loc": m: map, + "loc": f: Int as int257, "name": { "id": 6, "kind": "id", - "loc": m, - "text": "m", + "loc": f, + "text": "f", }, "type": { - "id": 9, - "keyStorageType": null, - "keyType": { - "id": 7, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - "kind": "map_type", - "loc": map, - "valueStorageType": null, - "valueType": { - "id": 8, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - }, - }, - { - "attributes": [], - "id": 18, - "kind": "function_def", - "loc": fun test() { foreach(_, _ in self.m) { } }, - "name": { - "id": 11, - "kind": "id", - "loc": test, - "text": "test", + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", }, - "params": [], - "return": null, - "statements": [ - { - "id": 17, - "keyName": { - "id": 12, - "kind": "id", - "loc": _, - "text": "_", - }, - "kind": "statement_foreach", - "loc": foreach(_, _ in self.m) { }, - "map": { - "aggregate": { - "id": 14, - "kind": "id", - "loc": self, - "text": "self", - }, - "field": { - "id": 15, - "kind": "id", - "loc": m, - "text": "m", - }, - "id": 16, - "kind": "field_access", - "loc": self.m, - }, - "statements": [], - "valueName": { - "id": 13, - "kind": "id", - "loc": _, - "text": "_", - }, - }, - ], }, ], - "id": 19, + "id": 10, "kind": "trait", - "loc": trait TraitWithForeach { - m: map; - - fun test() { foreach(_, _ in self.m) { } } + "loc": trait Foo { + f: Int as int257; }, "name": { "id": 5, "kind": "id", - "loc": TraitWithForeach, - "text": "TraitWithForeach", + "loc": Foo, + "text": "Foo", }, "traits": [], }, @@ -15557,139 +19734,56 @@ exports[`resolveDescriptors should resolve descriptors for trait-foreach 1`] = ` "fields": [ { "abi": { - "name": "m", + "name": "f", "type": { - "key": "int", - "keyFormat": undefined, - "kind": "dict", - "value": "int", - "valueFormat": undefined, + "format": 257, + "kind": "simple", + "optional": false, + "type": "int", }, }, - "as": null, + "as": "int257", "ast": { - "as": null, - "id": 10, + "as": { + "id": 8, + "kind": "id", + "loc": int257, + "text": "int257", + }, + "id": 9, "initializer": null, "kind": "field_decl", - "loc": m: map, + "loc": f: Int as int257, "name": { "id": 6, "kind": "id", - "loc": m, - "text": "m", + "loc": f, + "text": "f", }, "type": { - "id": 9, - "keyStorageType": null, - "keyType": { - "id": 7, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - "kind": "map_type", - "loc": map, - "valueStorageType": null, - "valueType": { - "id": 8, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, + "id": 7, + "kind": "type_id", + "loc": Int, + "text": "Int", }, }, "default": undefined, "index": 0, - "loc": m: map, - "name": "m", + "loc": f: Int as int257, + "name": "f", "type": { - "key": "Int", - "keyAs": null, - "kind": "map", - "value": "Int", - "valueAs": null, - }, - }, - ], - "functions": Map { - "test" => { - "ast": { - "attributes": [], - "id": 18, - "kind": "function_def", - "loc": fun test() { foreach(_, _ in self.m) { } }, - "name": { - "id": 11, - "kind": "id", - "loc": test, - "text": "test", - }, - "params": [], - "return": null, - "statements": [ - { - "id": 17, - "keyName": { - "id": 12, - "kind": "id", - "loc": _, - "text": "_", - }, - "kind": "statement_foreach", - "loc": foreach(_, _ in self.m) { }, - "map": { - "aggregate": { - "id": 14, - "kind": "id", - "loc": self, - "text": "self", - }, - "field": { - "id": 15, - "kind": "id", - "loc": m, - "text": "m", - }, - "id": 16, - "kind": "field_access", - "loc": self.m, - }, - "statements": [], - "valueName": { - "id": 13, - "kind": "id", - "loc": _, - "text": "_", - }, - }, - ], - }, - "isAbstract": false, - "isGetter": false, - "isInline": false, - "isMutating": true, - "isOverride": false, - "isVirtual": false, - "methodId": null, - "name": "test", - "origin": "user", - "params": [], - "returns": { - "kind": "void", - }, - "self": { "kind": "ref", - "name": "TraitWithForeach", + "name": "Int", "optional": false, }, }, - }, + ], + "functions": Map {}, "header": null, "init": null, "interfaces": [], "kind": "trait", - "name": "TraitWithForeach", + "name": "Foo", "origin": "user", "partialFieldCount": 0, "receivers": [], @@ -15702,7 +19796,7 @@ exports[`resolveDescriptors should resolve descriptors for trait-foreach 1`] = ` "declarations": [], "id": 4, "kind": "trait", - "loc": trait BaseTrait { }, + "loc": trait BaseTrait {}, "name": { "id": 3, "kind": "id", @@ -15729,12 +19823,12 @@ exports[`resolveDescriptors should resolve descriptors for trait-foreach 1`] = ` "uid": 1020, }, ], - "uid": 20892, + "uid": 10576, }, ], - "uid": 44104, + "uid": 8387, }, ] `; -exports[`resolveDescriptors should resolve descriptors for trait-foreach 2`] = `[]`; +exports[`resolveDescriptors should resolve descriptors for trait-with-as-typed-int257-field-with-inheritance-without-typed-field 2`] = `[]`; diff --git a/src/types/resolveDescriptors.ts b/src/types/resolveDescriptors.ts index bd82e7ade..6f24e8037 100644 --- a/src/types/resolveDescriptors.ts +++ b/src/types/resolveDescriptors.ts @@ -560,12 +560,6 @@ export function resolveDescriptors(ctx: CompilerContext, Ast: FactoryAst) { traitDecl.loc, ); } - if (traitDecl.as) { - throwCompilationError( - `Trait field cannot have serialization specifier`, - traitDecl.loc, - ); - } if (traitDecl.initializer) { throwCompilationError( `Trait field cannot have an initializer`, @@ -1518,6 +1512,10 @@ export function resolveDescriptors(ctx: CompilerContext, Ast: FactoryAst) { // Verify trait fields // + function printFieldTypeRefWithAs(ex: FieldDescription) { + return printTypeRef(ex.type) + (ex.as !== null ? ` as ${ex.as}` : ""); + } + for (const t of types.values()) { for (const tr of t.traits) { // Check that trait is valid @@ -1552,6 +1550,20 @@ export function resolveDescriptors(ctx: CompilerContext, Ast: FactoryAst) { `Trait "${tr.name}" requires field "${f.name}" of type "${printTypeRef(f.type)}"`, t.ast.loc, ); + } else if ( + f.as !== ex.as && + !( + (f.as === "int257" && ex.as === null) || + (f.as === null && ex.as === "int257") + ) + ) { + const expected = printFieldTypeRefWithAs(f); + const actual = printFieldTypeRefWithAs(ex); + + throwCompilationError( + `Trait "${tr.name}" requires field "${f.name}" of type "${expected}", but "${actual}" given`, + ex.ast.loc, + ); } } } diff --git a/src/types/test-failed/contract-without-as-typed-field-inherited-with-it.tact b/src/types/test-failed/contract-without-as-typed-field-inherited-with-it.tact new file mode 100644 index 000000000..1d277be61 --- /dev/null +++ b/src/types/test-failed/contract-without-as-typed-field-inherited-with-it.tact @@ -0,0 +1,11 @@ +primitive Int; + +trait BaseTrait {} + +trait Foo { + f: Int; +} + +contract SomeContract with Foo { + f: Int as coins; +} diff --git a/src/types/test-failed/trait-with-as-typed-field-for-contract-with-other-specialization.tact b/src/types/test-failed/trait-with-as-typed-field-for-contract-with-other-specialization.tact new file mode 100644 index 000000000..000881647 --- /dev/null +++ b/src/types/test-failed/trait-with-as-typed-field-for-contract-with-other-specialization.tact @@ -0,0 +1,11 @@ +primitive Int; + +trait BaseTrait {} + +trait Foo { + f: Int as int32; +} + +contract SomeContract with Foo { + f: Int as int16 = 0; +} diff --git a/src/types/test-failed/trait-with-as-typed-field-for-contract-with-other-type.tact b/src/types/test-failed/trait-with-as-typed-field-for-contract-with-other-type.tact new file mode 100644 index 000000000..64fe8a31b --- /dev/null +++ b/src/types/test-failed/trait-with-as-typed-field-for-contract-with-other-type.tact @@ -0,0 +1,16 @@ +primitive Int; +primitive Cell; + +trait BaseTrait {} + +trait Foo { + f: Int as int32; +} + +contract SomeContract with Foo { + f: Cell; + + init(f: Cell) { + self.f = f; + } +} diff --git a/src/types/test-failed/trait-with-as-typed-field-for-contract.tact b/src/types/test-failed/trait-with-as-typed-field-for-contract.tact new file mode 100644 index 000000000..77b1bebc9 --- /dev/null +++ b/src/types/test-failed/trait-with-as-typed-field-for-contract.tact @@ -0,0 +1,11 @@ +primitive Int; + +trait BaseTrait {} + +trait Foo { + f: Int as int32; +} + +contract SomeContract with Foo { + f: Int; +} diff --git a/src/types/test-failed/trait-with-as-typed-field-for-trait-with-other-specialization.tact b/src/types/test-failed/trait-with-as-typed-field-for-trait-with-other-specialization.tact new file mode 100644 index 000000000..4ddbbf526 --- /dev/null +++ b/src/types/test-failed/trait-with-as-typed-field-for-trait-with-other-specialization.tact @@ -0,0 +1,11 @@ +primitive Int; + +trait BaseTrait {} + +trait Foo { + f: Int as int32; +} + +trait SomeTrait with Foo { + f: Int as int16; +} diff --git a/src/types/test-failed/trait-with-as-typed-field-for-trait-with-other-type.tact b/src/types/test-failed/trait-with-as-typed-field-for-trait-with-other-type.tact new file mode 100644 index 000000000..1e2d4a999 --- /dev/null +++ b/src/types/test-failed/trait-with-as-typed-field-for-trait-with-other-type.tact @@ -0,0 +1,12 @@ +primitive Int; +primitive Cell; + +trait BaseTrait {} + +trait Foo { + f: Int as int32; +} + +trait SomeTrait with Foo { + f: Cell; +} diff --git a/src/types/test-failed/trait-with-as-typed-field-for-trait.tact b/src/types/test-failed/trait-with-as-typed-field-for-trait.tact new file mode 100644 index 000000000..ff787b323 --- /dev/null +++ b/src/types/test-failed/trait-with-as-typed-field-for-trait.tact @@ -0,0 +1,11 @@ +primitive Int; + +trait BaseTrait {} + +trait Foo { + f: Int as int32; +} + +trait SomeTrait with Foo { + f: Int; +} diff --git a/src/types/test-failed/trait-with-as-typed-field-in-diamond-inheritance-and-other-specialization.tact b/src/types/test-failed/trait-with-as-typed-field-in-diamond-inheritance-and-other-specialization.tact new file mode 100644 index 000000000..69bb2360c --- /dev/null +++ b/src/types/test-failed/trait-with-as-typed-field-in-diamond-inheritance-and-other-specialization.tact @@ -0,0 +1,23 @@ +primitive Int; + +trait BaseTrait {} + +trait T { + f1: Int as int32; +} + +trait T2 with T { + f1: Int as int32; + f2: Int as int32; +} + +trait T3 with T { + f1: Int as int32; + f3: Int as int32; +} + +trait SomeTrait with T2, T3 { + f1: Int as int32; + f2: Int as int16; + f3: Int as int32; +} diff --git a/src/types/test-failed/trait-with-as-typed-field-with-unsupported-format.tact b/src/types/test-failed/trait-with-as-typed-field-with-unsupported-format.tact new file mode 100644 index 000000000..c7164e9f2 --- /dev/null +++ b/src/types/test-failed/trait-with-as-typed-field-with-unsupported-format.tact @@ -0,0 +1,7 @@ +primitive Int; + +trait BaseTrait {} + +trait Foo { + f: Int as foo; +} diff --git a/src/types/test-failed/trait-with-as-typed-int257-field-for-trait-with-as-typed-coins-field.tact b/src/types/test-failed/trait-with-as-typed-int257-field-for-trait-with-as-typed-coins-field.tact new file mode 100644 index 000000000..2721eebb3 --- /dev/null +++ b/src/types/test-failed/trait-with-as-typed-int257-field-for-trait-with-as-typed-coins-field.tact @@ -0,0 +1,11 @@ +primitive Int; + +trait BaseTrait {} + +trait Trait { + i: Int as int257; +} + +contract Foo with Trait { + i: Int as coins = 0; +} diff --git a/src/types/test-failed/trait-without-as-typed-field-inherited-with-it.tact b/src/types/test-failed/trait-without-as-typed-field-inherited-with-it.tact new file mode 100644 index 000000000..fd39cf806 --- /dev/null +++ b/src/types/test-failed/trait-without-as-typed-field-inherited-with-it.tact @@ -0,0 +1,11 @@ +primitive Int; + +trait BaseTrait {} + +trait Foo { + f: Int; +} + +trait SomeTrait with Foo { + f: Int as int32; +} diff --git a/src/types/test/contract-with-as-typed-field.tact b/src/types/test/contract-with-as-typed-field.tact new file mode 100644 index 000000000..342f16a34 --- /dev/null +++ b/src/types/test/contract-with-as-typed-field.tact @@ -0,0 +1,11 @@ +primitive Int; + +trait BaseTrait {} + +trait Foo { + f: Int as int32; +} + +contract SomeContract with Foo { + f: Int as int32; +} diff --git a/src/types/test/trait-int-field-with-inheritance-with-as-typed-int257-field.tact b/src/types/test/trait-int-field-with-inheritance-with-as-typed-int257-field.tact new file mode 100644 index 000000000..ad79be994 --- /dev/null +++ b/src/types/test/trait-int-field-with-inheritance-with-as-typed-int257-field.tact @@ -0,0 +1,11 @@ +primitive Int; + +trait BaseTrait {} + +trait Foo { + f: Int; +} + +trait SomeTrait with Foo { + f: Int as int257; +} diff --git a/src/types/test/trait-with-as-typed-field-in-diamond-inheritance.tact b/src/types/test/trait-with-as-typed-field-in-diamond-inheritance.tact new file mode 100644 index 000000000..32937ff13 --- /dev/null +++ b/src/types/test/trait-with-as-typed-field-in-diamond-inheritance.tact @@ -0,0 +1,23 @@ +primitive Int; + +trait BaseTrait {} + +trait T { + f1: Int as int32; +} + +trait T2 with T { + f1: Int as int32; + f2: Int as int32; +} + +trait T3 with T { + f1: Int as int32; + f3: Int as int32; +} + +trait SomeTrait with T2, T3 { + f1: Int as int32; + f2: Int as int32; + f3: Int as int32; +} diff --git a/src/types/test/trait-with-as-typed-field.tact b/src/types/test/trait-with-as-typed-field.tact new file mode 100644 index 000000000..83b36de7b --- /dev/null +++ b/src/types/test/trait-with-as-typed-field.tact @@ -0,0 +1,11 @@ +primitive Int; + +trait BaseTrait {} + +trait Foo { + f: Int as int32; +} + +trait SomeTrait with Foo { + f: Int as int32; +} diff --git a/src/types/test/trait-with-as-typed-int257-field-with-inheritance-without-typed-field.tact b/src/types/test/trait-with-as-typed-int257-field-with-inheritance-without-typed-field.tact new file mode 100644 index 000000000..1d8272396 --- /dev/null +++ b/src/types/test/trait-with-as-typed-int257-field-with-inheritance-without-typed-field.tact @@ -0,0 +1,11 @@ +primitive Int; + +trait BaseTrait {} + +trait Foo { + f: Int as int257; +} + +trait SomeTrait with Foo { + f: Int; +}