Skip to content

Commit

Permalink
add legacyAuthorized field to reference types
Browse files Browse the repository at this point in the history
  • Loading branch information
dsainati1 committed Jan 23, 2024
1 parent 45a736a commit 110bd77
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 19 deletions.
6 changes: 3 additions & 3 deletions runtime/ast/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const (
AccessContract
AccessAccount
AccessAll
PubSettableLegacy // Deprecated
AccessPubSettableLegacy // Deprecated
)

func PrimitiveAccessCount() int {
Expand Down Expand Up @@ -254,7 +254,7 @@ func (a PrimitiveAccess) Keyword() string {
return "access(account)"
case AccessContract:
return "access(contract)"
case PubSettableLegacy:
case AccessPubSettableLegacy:
return "pub(set)"

Check warning on line 258 in runtime/ast/access.go

View check run for this annotation

Codecov / codecov/patch

runtime/ast/access.go#L257-L258

Added lines #L257 - L258 were not covered by tests
}

Expand All @@ -273,7 +273,7 @@ func (a PrimitiveAccess) Description() string {
return "account"
case AccessContract:
return "contract"
case PubSettableLegacy:
case AccessPubSettableLegacy:
return "legacy public settable"

Check warning on line 277 in runtime/ast/access.go

View check run for this annotation

Codecov / codecov/patch

runtime/ast/access.go#L276-L277

Added lines #L276 - L277 were not covered by tests
}

Expand Down
6 changes: 3 additions & 3 deletions runtime/ast/primitiveaccess_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions runtime/ast/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,10 @@ func (t *FunctionType) CheckEqual(other Type, checker TypeEqualityChecker) error

// ReferenceType
type ReferenceType struct {
Type Type `json:"ReferencedType"`
StartPos Position `json:"-"`
Authorization Authorization `json:"Authorization"`
Type Type `json:"ReferencedType"`
StartPos Position `json:"-"`
LegacyAuthorized bool
Authorization Authorization `json:"Authorization"`
}

var _ Type = &ReferenceType{}
Expand Down
1 change: 1 addition & 0 deletions runtime/ast/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,7 @@ func TestReferenceType_MarshalJSON(t *testing.T) {
`
{
"Type": "ReferenceType",
"LegacyAuthorized": false,
"Authorization": {
"ConjunctiveElements": [
{
Expand Down
2 changes: 1 addition & 1 deletion runtime/old_parser/declaration.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func parseAccess(p *parser) (ast.PrimitiveAccess, error) {
return ast.AccessNotSpecified, err
}

return ast.PubSettableLegacy, nil
return ast.AccessPubSettableLegacy, nil

case keywordAccess:
// Skip the `access` keyword
Expand Down
10 changes: 5 additions & 5 deletions runtime/old_parser/declaration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ func TestParseAccess(t *testing.T) {
require.Empty(t, errs)

utils.AssertEqualWithDiff(t,
ast.PubSettableLegacy,
ast.AccessPubSettableLegacy,
result,
)
})
Expand Down Expand Up @@ -2648,7 +2648,7 @@ func TestParseCompositeDeclaration(t *testing.T) {
Members: ast.NewUnmeteredMembers(
[]ast.Declaration{
&ast.FieldDeclaration{
Access: ast.PubSettableLegacy,
Access: ast.AccessPubSettableLegacy,
VariableKind: ast.VariableKindVariable,
Identifier: ast.Identifier{
Identifier: "foo",
Expand Down Expand Up @@ -3031,7 +3031,7 @@ func TestParseAttachmentDeclaration(t *testing.T) {
Members: ast.NewUnmeteredMembers(
[]ast.Declaration{
&ast.FieldDeclaration{
Access: ast.PubSettableLegacy,
Access: ast.AccessPubSettableLegacy,
VariableKind: ast.VariableKindVariable,
Identifier: ast.Identifier{
Identifier: "foo",
Expand Down Expand Up @@ -3233,7 +3233,7 @@ func TestParseInterfaceDeclaration(t *testing.T) {
Members: ast.NewUnmeteredMembers(
[]ast.Declaration{
&ast.FieldDeclaration{
Access: ast.PubSettableLegacy,
Access: ast.AccessPubSettableLegacy,
VariableKind: ast.VariableKindVariable,
Identifier: ast.Identifier{
Identifier: "foo",
Expand Down Expand Up @@ -4423,7 +4423,7 @@ func TestParseStructure(t *testing.T) {
Members: ast.NewUnmeteredMembers(
[]ast.Declaration{
&ast.FieldDeclaration{
Access: ast.PubSettableLegacy,
Access: ast.AccessPubSettableLegacy,
VariableKind: ast.VariableKindVariable,
Identifier: ast.Identifier{
Identifier: "foo",
Expand Down
7 changes: 5 additions & 2 deletions runtime/old_parser/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,15 @@ func init() {
return nil, err
}

Check warning on line 170 in runtime/old_parser/type.go

View check run for this annotation

Codecov / codecov/patch

runtime/old_parser/type.go#L169-L170

Added lines #L169 - L170 were not covered by tests

return ast.NewReferenceType(
refType := ast.NewReferenceType(
p.memoryGauge,
nil,
right,
token.StartPos,
), nil
)
refType.LegacyAuthorized = true

return refType, nil

default:
return parseNominalTypeRemainder(p, token)
Expand Down
6 changes: 4 additions & 2 deletions runtime/old_parser/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ func TestParseReferenceType(t *testing.T) {

utils.AssertEqualWithDiff(t,
&ast.ReferenceType{
Authorization: nil,
Authorization: nil,
LegacyAuthorized: true,
Type: &ast.NominalType{
Identifier: ast.Identifier{
Identifier: "Int",
Expand Down Expand Up @@ -2739,7 +2740,8 @@ func TestParseAuthorizedReferenceType(t *testing.T) {
TypeAnnotation: &ast.TypeAnnotation{
IsResource: false,
Type: &ast.ReferenceType{
Authorization: nil,
LegacyAuthorized: true,
Authorization: nil,
Type: &ast.NominalType{
Identifier: ast.Identifier{
Identifier: "R", Pos: ast.Position{Offset: 21, Line: 2, Column: 20}},
Expand Down

0 comments on commit 110bd77

Please sign in to comment.