diff --git a/migrations/statictypes/statictype_migration.go b/migrations/statictypes/statictype_migration.go index 34773ea4f3..79ea8570d2 100644 --- a/migrations/statictypes/statictype_migration.go +++ b/migrations/statictypes/statictype_migration.go @@ -182,9 +182,12 @@ func (m *StaticTypeMigration) maybeConvertStaticType(staticType, parentType inte } case *interpreter.CapabilityStaticType: - convertedBorrowType := m.maybeConvertStaticType(staticType.BorrowType, staticType) - if convertedBorrowType != nil { - return interpreter.NewCapabilityStaticType(nil, convertedBorrowType) + borrowType := staticType.BorrowType + if borrowType != nil { + convertedBorrowType := m.maybeConvertStaticType(borrowType, staticType) + if convertedBorrowType != nil { + return interpreter.NewCapabilityStaticType(nil, convertedBorrowType) + } } case *interpreter.IntersectionStaticType: diff --git a/migrations/statictypes/statictype_migration_test.go b/migrations/statictypes/statictype_migration_test.go index f90f7abfba..be9ae74853 100644 --- a/migrations/statictypes/statictype_migration_test.go +++ b/migrations/statictypes/statictype_migration_test.go @@ -118,14 +118,34 @@ func TestStaticTypeMigration(t *testing.T) { actual := migrate(t, staticTypeMigration, - interpreter.NewTypeValue(nil, nil), + interpreter.NewUnmeteredTypeValue(nil), // NOTE: atree value validation is disabled, // because the type value has a nil type (which indicates an invalid or unknown type), // and invalid unknown types are always unequal false, ) assert.Equal(t, - interpreter.NewTypeValue(nil, nil), + interpreter.NewUnmeteredTypeValue(nil), + actual, + ) + }) + + t.Run("TypeValue with unparameterized Capability type", func(t *testing.T) { + t.Parallel() + + staticTypeMigration := NewStaticTypeMigration() + + actual := migrate(t, + staticTypeMigration, + interpreter.NewUnmeteredTypeValue( + interpreter.NewCapabilityStaticType(nil, nil), + ), + true, + ) + assert.Equal(t, + interpreter.NewUnmeteredTypeValue( + interpreter.NewCapabilityStaticType(nil, nil), + ), actual, ) })