diff --git a/runtime/sema/account_capability_controller.gen.go b/runtime/sema/account_capability_controller.gen.go index 02d09d0769..710ec457b6 100644 --- a/runtime/sema/account_capability_controller.gen.go +++ b/runtime/sema/account_capability_controller.gen.go @@ -105,6 +105,7 @@ var AccountCapabilityControllerType = &SimpleType{ TypeTag: AccountCapabilityControllerTypeTag, IsResource: false, Storable: false, + Primitive: false, Equatable: false, Comparable: false, Exportable: false, diff --git a/runtime/sema/any_type.go b/runtime/sema/any_type.go index 7feaaf28dc..a95a74bf46 100644 --- a/runtime/sema/any_type.go +++ b/runtime/sema/any_type.go @@ -28,6 +28,7 @@ var AnyType = &SimpleType{ IsResource: false, // `Any` is never a valid type in user programs Storable: true, + Primitive: false, Equatable: false, Comparable: false, // `Any` is never a valid type in user programs diff --git a/runtime/sema/anyattachment_types.go b/runtime/sema/anyattachment_types.go index ef154c4926..aff86b40ae 100644 --- a/runtime/sema/anyattachment_types.go +++ b/runtime/sema/anyattachment_types.go @@ -27,6 +27,7 @@ var AnyResourceAttachmentType = &SimpleType{ TypeID: AnyResourceAttachmentTypeName, TypeTag: AnyResourceAttachmentTypeTag, IsResource: true, + Primitive: false, // The actual storability of a value is checked at run-time Storable: true, Equatable: false, @@ -45,6 +46,7 @@ var AnyStructAttachmentType = &SimpleType{ TypeID: AnyStructAttachmentTypeName, TypeTag: AnyStructAttachmentTypeTag, IsResource: false, + Primitive: false, // The actual storability of a value is checked at run-time Storable: true, Equatable: false, diff --git a/runtime/sema/anyresource_type.go b/runtime/sema/anyresource_type.go index 6b20d9563a..9c255dfcc8 100644 --- a/runtime/sema/anyresource_type.go +++ b/runtime/sema/anyresource_type.go @@ -25,6 +25,7 @@ var AnyResourceType = &SimpleType{ TypeID: "AnyResource", TypeTag: AnyResourceTypeTag, IsResource: true, + Primitive: false, // The actual storability of a value is checked at run-time Storable: true, Equatable: false, diff --git a/runtime/sema/anystruct_type.go b/runtime/sema/anystruct_type.go index a4739610a3..a9d5c9c0e9 100644 --- a/runtime/sema/anystruct_type.go +++ b/runtime/sema/anystruct_type.go @@ -27,6 +27,7 @@ var AnyStructType = &SimpleType{ IsResource: false, // The actual storability of a value is checked at run-time Storable: true, + Primitive: false, Equatable: false, Comparable: false, Exportable: true, diff --git a/runtime/sema/block.gen.go b/runtime/sema/block.gen.go index 7c490c3a0c..f28e6f2d77 100644 --- a/runtime/sema/block.gen.go +++ b/runtime/sema/block.gen.go @@ -72,6 +72,7 @@ var BlockType = &SimpleType{ TypeTag: BlockTypeTag, IsResource: false, Storable: false, + Primitive: false, Equatable: false, Comparable: false, Exportable: false, diff --git a/runtime/sema/bool_type.go b/runtime/sema/bool_type.go index 1870777d78..0ca7d61b8c 100644 --- a/runtime/sema/bool_type.go +++ b/runtime/sema/bool_type.go @@ -26,6 +26,7 @@ var BoolType = &SimpleType{ TypeTag: BoolTypeTag, IsResource: false, Storable: true, + Primitive: true, Equatable: true, Comparable: true, Exportable: true, diff --git a/runtime/sema/character.cdc b/runtime/sema/character.cdc index 48bf5b170e..7b54afdf5d 100644 --- a/runtime/sema/character.cdc +++ b/runtime/sema/character.cdc @@ -1,6 +1,6 @@ access(all) -struct Character: Storable, Equatable, Comparable, Exportable, Importable { +struct Character: Storable, Primitive, Equatable, Comparable, Exportable, Importable { /// The byte array of the UTF-8 encoding. access(all) diff --git a/runtime/sema/character.gen.go b/runtime/sema/character.gen.go index 69909c376f..3ba8c946b0 100644 --- a/runtime/sema/character.gen.go +++ b/runtime/sema/character.gen.go @@ -53,6 +53,7 @@ var CharacterType = &SimpleType{ TypeTag: CharacterTypeTag, IsResource: false, Storable: true, + Primitive: true, Equatable: true, Comparable: true, Exportable: true, diff --git a/runtime/sema/deployedcontract.gen.go b/runtime/sema/deployedcontract.gen.go index 864c5dd718..1fed899bef 100644 --- a/runtime/sema/deployedcontract.gen.go +++ b/runtime/sema/deployedcontract.gen.go @@ -81,6 +81,7 @@ var DeployedContractType = &SimpleType{ TypeTag: DeployedContractTypeTag, IsResource: false, Storable: false, + Primitive: false, Equatable: false, Comparable: false, Exportable: false, diff --git a/runtime/sema/gen/main.go b/runtime/sema/gen/main.go index b7778b0a97..b69133a6f2 100644 --- a/runtime/sema/gen/main.go +++ b/runtime/sema/gen/main.go @@ -155,6 +155,7 @@ type typeDecl struct { fullTypeName string compositeKind common.CompositeKind storable bool + primitive bool equatable bool exportable bool comparable bool @@ -524,6 +525,15 @@ func (g *generator) VisitCompositeDeclaration(decl *ast.CompositeDeclaration) (_ } typeDecl.storable = true + case "Primitive": + if !generateSimpleType { + panic(fmt.Errorf( + "composite types cannot be explicitly marked as primitive: %s", + g.currentTypeID(), + )) + } + typeDecl.primitive = true + case "Equatable": if !generateSimpleType { panic(fmt.Errorf( @@ -1576,6 +1586,7 @@ func simpleTypeLiteral(ty *typeDecl) dst.Expr { // tag: TestTypeTag, // IsResource: true, // Storable: false, + // Primitive: false, // Equatable: false, // Comparable: false, // Exportable: false, @@ -1590,6 +1601,7 @@ func simpleTypeLiteral(ty *typeDecl) dst.Expr { goKeyValue("TypeTag", typeTagVarIdent(ty.fullTypeName)), goKeyValue("IsResource", goBoolLit(isResource)), goKeyValue("Storable", goBoolLit(ty.storable)), + goKeyValue("Primitive", goBoolLit(ty.primitive)), goKeyValue("Equatable", goBoolLit(ty.equatable)), goKeyValue("Comparable", goBoolLit(ty.comparable)), goKeyValue("Exportable", goBoolLit(ty.exportable)), diff --git a/runtime/sema/gen/testdata/comparable/test.golden.go b/runtime/sema/gen/testdata/comparable/test.golden.go index c088f5d175..1814db508e 100644 --- a/runtime/sema/gen/testdata/comparable/test.golden.go +++ b/runtime/sema/gen/testdata/comparable/test.golden.go @@ -30,6 +30,7 @@ var TestType = &sema.SimpleType{ TypeTag: TestTypeTag, IsResource: false, Storable: false, + Primitive: false, Equatable: false, Comparable: true, Exportable: false, diff --git a/runtime/sema/gen/testdata/docstrings/test.golden.go b/runtime/sema/gen/testdata/docstrings/test.golden.go index a35767c913..93ba66c503 100644 --- a/runtime/sema/gen/testdata/docstrings/test.golden.go +++ b/runtime/sema/gen/testdata/docstrings/test.golden.go @@ -113,6 +113,7 @@ var DocstringsType = &sema.SimpleType{ TypeTag: DocstringsTypeTag, IsResource: false, Storable: false, + Primitive: false, Equatable: false, Comparable: false, Exportable: false, diff --git a/runtime/sema/gen/testdata/equatable/test.golden.go b/runtime/sema/gen/testdata/equatable/test.golden.go index e102e7e6de..8f1a2b9d96 100644 --- a/runtime/sema/gen/testdata/equatable/test.golden.go +++ b/runtime/sema/gen/testdata/equatable/test.golden.go @@ -30,6 +30,7 @@ var TestType = &sema.SimpleType{ TypeTag: TestTypeTag, IsResource: false, Storable: false, + Primitive: false, Equatable: true, Comparable: false, Exportable: false, diff --git a/runtime/sema/gen/testdata/exportable/test.golden.go b/runtime/sema/gen/testdata/exportable/test.golden.go index 3124209d4a..215b830574 100644 --- a/runtime/sema/gen/testdata/exportable/test.golden.go +++ b/runtime/sema/gen/testdata/exportable/test.golden.go @@ -30,6 +30,7 @@ var TestType = &sema.SimpleType{ TypeTag: TestTypeTag, IsResource: false, Storable: false, + Primitive: false, Equatable: false, Comparable: false, Exportable: true, diff --git a/runtime/sema/gen/testdata/fields/test.golden.go b/runtime/sema/gen/testdata/fields/test.golden.go index 950c618e93..eb4a381f7f 100644 --- a/runtime/sema/gen/testdata/fields/test.golden.go +++ b/runtime/sema/gen/testdata/fields/test.golden.go @@ -150,6 +150,7 @@ var TestType = &sema.SimpleType{ TypeTag: TestTypeTag, IsResource: false, Storable: false, + Primitive: false, Equatable: false, Comparable: false, Exportable: false, diff --git a/runtime/sema/gen/testdata/functions/test.golden.go b/runtime/sema/gen/testdata/functions/test.golden.go index 2c22638b28..8a1baee350 100644 --- a/runtime/sema/gen/testdata/functions/test.golden.go +++ b/runtime/sema/gen/testdata/functions/test.golden.go @@ -185,6 +185,7 @@ var TestType = &sema.SimpleType{ TypeTag: TestTypeTag, IsResource: false, Storable: false, + Primitive: false, Equatable: false, Comparable: false, Exportable: false, diff --git a/runtime/sema/gen/testdata/importable/test.golden.go b/runtime/sema/gen/testdata/importable/test.golden.go index 243be9b153..1a464895a5 100644 --- a/runtime/sema/gen/testdata/importable/test.golden.go +++ b/runtime/sema/gen/testdata/importable/test.golden.go @@ -30,6 +30,7 @@ var TestType = &sema.SimpleType{ TypeTag: TestTypeTag, IsResource: false, Storable: false, + Primitive: false, Equatable: false, Comparable: false, Exportable: false, diff --git a/runtime/sema/gen/testdata/member_accessible/test.golden.go b/runtime/sema/gen/testdata/member_accessible/test.golden.go index ec49013df0..7c807a9fa0 100644 --- a/runtime/sema/gen/testdata/member_accessible/test.golden.go +++ b/runtime/sema/gen/testdata/member_accessible/test.golden.go @@ -30,6 +30,7 @@ var TestType = &sema.SimpleType{ TypeTag: TestTypeTag, IsResource: false, Storable: false, + Primitive: false, Equatable: false, Comparable: false, Exportable: false, diff --git a/runtime/sema/gen/testdata/primitive/helper.go b/runtime/sema/gen/testdata/primitive/helper.go new file mode 100644 index 0000000000..f9fe69a546 --- /dev/null +++ b/runtime/sema/gen/testdata/primitive/helper.go @@ -0,0 +1,23 @@ +/* + * Cadence - The resource-oriented smart contract programming language + * + * Copyright Dapper Labs, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package primitive + +import "github.com/onflow/cadence/runtime/sema" + +var TestTypeTag sema.TypeTag diff --git a/runtime/sema/gen/testdata/primitive/test.cdc b/runtime/sema/gen/testdata/primitive/test.cdc new file mode 100644 index 0000000000..a1d0834ec7 --- /dev/null +++ b/runtime/sema/gen/testdata/primitive/test.cdc @@ -0,0 +1 @@ +access(all) struct Test: Primitive {} diff --git a/runtime/sema/gen/testdata/primitive/test.golden.go b/runtime/sema/gen/testdata/primitive/test.golden.go new file mode 100644 index 0000000000..d4d63f223a --- /dev/null +++ b/runtime/sema/gen/testdata/primitive/test.golden.go @@ -0,0 +1,39 @@ +// Code generated from testdata/primitive/test.cdc. DO NOT EDIT. +/* + * Cadence - The resource-oriented smart contract programming language + * + * Copyright Dapper Labs, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package primitive + +import "github.com/onflow/cadence/runtime/sema" + +const TestTypeName = "Test" + +var TestType = &sema.SimpleType{ + Name: TestTypeName, + QualifiedName: TestTypeName, + TypeID: TestTypeName, + TypeTag: TestTypeTag, + IsResource: false, + Storable: false, + Primitive: true, + Equatable: false, + Comparable: false, + Exportable: false, + Importable: false, + ContainFields: false, +} diff --git a/runtime/sema/gen/testdata/simple_resource/test.golden.go b/runtime/sema/gen/testdata/simple_resource/test.golden.go index a6876b92ce..fd5f4a640b 100644 --- a/runtime/sema/gen/testdata/simple_resource/test.golden.go +++ b/runtime/sema/gen/testdata/simple_resource/test.golden.go @@ -30,6 +30,7 @@ var TestType = &sema.SimpleType{ TypeTag: TestTypeTag, IsResource: true, Storable: false, + Primitive: false, Equatable: false, Comparable: false, Exportable: false, diff --git a/runtime/sema/gen/testdata/simple_struct/test.golden.go b/runtime/sema/gen/testdata/simple_struct/test.golden.go index 4606268f1d..78f5af724d 100644 --- a/runtime/sema/gen/testdata/simple_struct/test.golden.go +++ b/runtime/sema/gen/testdata/simple_struct/test.golden.go @@ -30,6 +30,7 @@ var TestType = &sema.SimpleType{ TypeTag: TestTypeTag, IsResource: false, Storable: false, + Primitive: false, Equatable: false, Comparable: false, Exportable: false, diff --git a/runtime/sema/gen/testdata/storable/test.golden.go b/runtime/sema/gen/testdata/storable/test.golden.go index 5a01604df9..e49e481d20 100644 --- a/runtime/sema/gen/testdata/storable/test.golden.go +++ b/runtime/sema/gen/testdata/storable/test.golden.go @@ -30,6 +30,7 @@ var TestType = &sema.SimpleType{ TypeTag: TestTypeTag, IsResource: false, Storable: true, + Primitive: false, Equatable: false, Comparable: false, Exportable: false, diff --git a/runtime/sema/hashable_struct.gen.go b/runtime/sema/hashable_struct.gen.go index 383d7d0d1e..27b7daf1b8 100644 --- a/runtime/sema/hashable_struct.gen.go +++ b/runtime/sema/hashable_struct.gen.go @@ -28,6 +28,7 @@ var HashableStructType = &SimpleType{ TypeTag: HashableStructTypeTag, IsResource: false, Storable: true, + Primitive: false, Equatable: false, Comparable: false, Exportable: true, diff --git a/runtime/sema/invalid_type.go b/runtime/sema/invalid_type.go index 409d50f5ab..789d0512d9 100644 --- a/runtime/sema/invalid_type.go +++ b/runtime/sema/invalid_type.go @@ -28,6 +28,7 @@ var InvalidType = &SimpleType{ TypeTag: InvalidTypeTag, IsResource: false, Storable: false, + Primitive: false, Equatable: false, Comparable: false, Exportable: false, diff --git a/runtime/sema/meta_type.go b/runtime/sema/meta_type.go index 6ee455c1ab..ce41f51e93 100644 --- a/runtime/sema/meta_type.go +++ b/runtime/sema/meta_type.go @@ -40,6 +40,7 @@ var MetaType = &SimpleType{ TypeTag: MetaTypeTag, IsResource: false, Storable: true, + Primitive: false, Equatable: true, Comparable: false, Exportable: true, diff --git a/runtime/sema/never_type.go b/runtime/sema/never_type.go index 0d3fe642f5..e8a39ac087 100644 --- a/runtime/sema/never_type.go +++ b/runtime/sema/never_type.go @@ -26,6 +26,7 @@ var NeverType = &SimpleType{ TypeTag: NeverTypeTag, IsResource: false, Storable: false, + Primitive: false, Equatable: false, Comparable: false, Exportable: false, diff --git a/runtime/sema/path_type.go b/runtime/sema/path_type.go index 0e94d17fda..636f9ff2a7 100644 --- a/runtime/sema/path_type.go +++ b/runtime/sema/path_type.go @@ -26,6 +26,7 @@ var PathType = &SimpleType{ TypeTag: PathTypeTag, IsResource: false, Storable: true, + Primitive: true, Equatable: true, Comparable: false, Exportable: true, @@ -42,6 +43,7 @@ var StoragePathType = &SimpleType{ TypeTag: StoragePathTypeTag, IsResource: false, Storable: true, + Primitive: true, Equatable: true, Comparable: false, Exportable: true, @@ -58,6 +60,7 @@ var CapabilityPathType = &SimpleType{ TypeTag: CapabilityPathTypeTag, IsResource: false, Storable: true, + Primitive: true, Equatable: true, Comparable: false, Exportable: true, @@ -74,6 +77,7 @@ var PublicPathType = &SimpleType{ TypeTag: PublicPathTypeTag, IsResource: false, Storable: true, + Primitive: true, Equatable: true, Comparable: false, Exportable: true, @@ -90,6 +94,7 @@ var PrivatePathType = &SimpleType{ TypeTag: PrivatePathTypeTag, IsResource: false, Storable: true, + Primitive: true, Equatable: true, Comparable: false, Exportable: true, diff --git a/runtime/sema/simple_type.go b/runtime/sema/simple_type.go index 139e9d992a..40c0b531ec 100644 --- a/runtime/sema/simple_type.go +++ b/runtime/sema/simple_type.go @@ -48,6 +48,7 @@ type SimpleType struct { Equatable bool Comparable bool Storable bool + Primitive bool IsResource bool ContainFields bool } @@ -82,6 +83,10 @@ func (t *SimpleType) IsResourceType() bool { return t.IsResource } +func (t *SimpleType) IsPrimitiveType() bool { + return t.Primitive +} + func (t *SimpleType) IsInvalidType() bool { return t == InvalidType } diff --git a/runtime/sema/storable_type.go b/runtime/sema/storable_type.go index 0c13b0e441..5e394806fe 100644 --- a/runtime/sema/storable_type.go +++ b/runtime/sema/storable_type.go @@ -35,6 +35,7 @@ var StorableType = &SimpleType{ // for e.g. parameters, return types, fields, etc. IsResource: false, Storable: true, + Primitive: false, Equatable: false, Comparable: false, Exportable: false, diff --git a/runtime/sema/storage_capability_controller.gen.go b/runtime/sema/storage_capability_controller.gen.go index 9ef52376db..199aae6971 100644 --- a/runtime/sema/storage_capability_controller.gen.go +++ b/runtime/sema/storage_capability_controller.gen.go @@ -137,6 +137,7 @@ var StorageCapabilityControllerType = &SimpleType{ TypeTag: StorageCapabilityControllerTypeTag, IsResource: false, Storable: false, + Primitive: false, Equatable: false, Comparable: false, Exportable: false, diff --git a/runtime/sema/string_type.go b/runtime/sema/string_type.go index bcb562c6d6..c54325579c 100644 --- a/runtime/sema/string_type.go +++ b/runtime/sema/string_type.go @@ -55,6 +55,7 @@ var StringType = &SimpleType{ TypeTag: StringTypeTag, IsResource: false, Storable: true, + Primitive: true, Equatable: true, Comparable: true, Exportable: true, diff --git a/runtime/sema/type.go b/runtime/sema/type.go index e99b80c536..2ecbc92822 100644 --- a/runtime/sema/type.go +++ b/runtime/sema/type.go @@ -105,6 +105,11 @@ type Type interface { QualifiedString() string Equal(other Type) bool + // IsPrimitiveType returns true if the type is itself a primitive, + // Note that the container of a primitive type (e.g. optionals, arrays, dictionaries, etc.) + // are not a primitive. + IsPrimitiveType() bool + // IsResourceType returns true if the type is itself a resource (a `CompositeType` with resource kind), // or it contains a resource type (e.g. for optionals, arrays, dictionaries, etc.) IsResourceType() bool @@ -670,6 +675,10 @@ func (t *OptionalType) IsResourceType() bool { return t.Type.IsResourceType() } +func (t *OptionalType) IsPrimitiveType() bool { + return t.Type.IsPrimitiveType() +} + func (t *OptionalType) IsInvalidType() bool { return t.Type.IsInvalidType() } @@ -879,6 +888,10 @@ func (*GenericType) IsResourceType() bool { return false } +func (*GenericType) IsPrimitiveType() bool { + return false +} + func (*GenericType) IsInvalidType() bool { return false } @@ -1179,6 +1192,10 @@ func (*NumericType) IsResourceType() bool { return false } +func (*NumericType) IsPrimitiveType() bool { + return true +} + func (*NumericType) IsInvalidType() bool { return false } @@ -1368,6 +1385,10 @@ func (*FixedPointNumericType) IsResourceType() bool { return false } +func (*FixedPointNumericType) IsPrimitiveType() bool { + return true +} + func (*FixedPointNumericType) IsInvalidType() bool { return false } @@ -2663,6 +2684,10 @@ func (t *VariableSizedType) IsResourceType() bool { return t.Type.IsResourceType() } +func (t *VariableSizedType) IsPrimitiveType() bool { + return false +} + func (t *VariableSizedType) IsInvalidType() bool { return t.Type.IsInvalidType() } @@ -2834,6 +2859,10 @@ func (t *ConstantSizedType) IsResourceType() bool { return t.Type.IsResourceType() } +func (t *ConstantSizedType) IsPrimitiveType() bool { + return false +} + func (t *ConstantSizedType) IsInvalidType() bool { return t.Type.IsInvalidType() } @@ -3383,6 +3412,10 @@ func (*FunctionType) IsResourceType() bool { return false } +func (t *FunctionType) IsPrimitiveType() bool { + return false +} + func (t *FunctionType) IsInvalidType() bool { for _, typeParameter := range t.TypeParameters { @@ -4549,6 +4582,10 @@ func (t *CompositeType) IsResourceType() bool { t.baseType.IsResourceType()) } +func (t *CompositeType) IsPrimitiveType() bool { + return false +} + func (*CompositeType) IsInvalidType() bool { return false } @@ -5346,6 +5383,10 @@ func (t *InterfaceType) IsResourceType() bool { return t.CompositeKind == common.CompositeKindResource } +func (t *InterfaceType) IsPrimitiveType() bool { + return false +} + func (t *InterfaceType) IsInvalidType() bool { return false } @@ -5602,6 +5643,10 @@ func (t *DictionaryType) IsResourceType() bool { t.ValueType.IsResourceType() } +func (t *DictionaryType) IsPrimitiveType() bool { + return false +} + func (t *DictionaryType) IsInvalidType() bool { return t.KeyType.IsInvalidType() || t.ValueType.IsInvalidType() @@ -6094,6 +6139,10 @@ func (t *ReferenceType) IsResourceType() bool { return false } +func (t *ReferenceType) IsPrimitiveType() bool { + return false +} + func (t *ReferenceType) IsInvalidType() bool { return t.Type.IsInvalidType() } @@ -6289,6 +6338,10 @@ func (*AddressType) IsResourceType() bool { return false } +func (*AddressType) IsPrimitiveType() bool { + return true +} + func (*AddressType) IsInvalidType() bool { return false } @@ -6900,6 +6953,10 @@ func (*TransactionType) IsResourceType() bool { return false } +func (*TransactionType) IsPrimitiveType() bool { + return false +} + func (*TransactionType) IsInvalidType() bool { return false } @@ -7099,6 +7156,10 @@ func (t *IntersectionType) IsResourceType() bool { return t.Types[0].IsResourceType() } +func (*IntersectionType) IsPrimitiveType() bool { + return false +} + func (t *IntersectionType) IsInvalidType() bool { for _, typ := range t.Types { if typ.IsInvalidType() { @@ -7349,6 +7410,10 @@ func (*CapabilityType) IsResourceType() bool { return false } +func (*CapabilityType) IsPrimitiveType() bool { + return false +} + func (t *CapabilityType) IsInvalidType() bool { if t.BorrowType == nil { return false @@ -7913,6 +7978,10 @@ func (t *EntitlementType) GetMembers() map[string]MemberResolver { return withBuiltinMembers(t, nil) } +func (t *EntitlementType) IsPrimitiveType() bool { + return false +} + func (t *EntitlementType) IsInvalidType() bool { return false } @@ -8056,6 +8125,10 @@ func (t *EntitlementMapType) GetMembers() map[string]MemberResolver { return withBuiltinMembers(t, nil) } +func (*EntitlementMapType) IsPrimitiveType() bool { + return false +} + func (t *EntitlementMapType) IsInvalidType() bool { return false } diff --git a/runtime/sema/void_type.go b/runtime/sema/void_type.go index 4ebe233b58..9135dbb719 100644 --- a/runtime/sema/void_type.go +++ b/runtime/sema/void_type.go @@ -26,6 +26,7 @@ var VoidType = &SimpleType{ TypeTag: VoidTypeTag, IsResource: false, Storable: false, + Primitive: false, Equatable: true, Comparable: false, Exportable: true,