# Cycle reference since changing to Default Actor Isolation Main Actor in nested structs

**URL:** <https://forums.swift.org/t/cycle-reference-since-changing-to-default-actor-isolation-main-actor-in-nested-structs/80745>\
**Category:** Using Swift\
**Tags:** codable, structs, mainactor\
**Created:** [June 27, 2025, 6:26pm UTC](https://forums.swift.org/t/cycle-reference-since-changing-to-default-actor-isolation-main-actor-in-nested-structs/80745 "2025-06-27T18:26:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Seyden](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/seyden/32/41672_2.png) [@Seyden](https://forums.swift.org/u/Seyden)\
**Post date:** [June 27, 2025, 6:26pm UTC](https://forums.swift.org/t/cycle-reference-since-changing-to-default-actor-isolation-main-actor-in-nested-structs/80745/1 "2025-06-27T18:26:02Z")

</div>

Hey guys,

since the new default actor isolation, i wanted to try to set my project to MainActor default actor.

After changing the setting i was getting basically an error for every struct that has Codable in it.

My code:

```swift
extension MyTestActor {
    struct Structs {}
}

extension MyTestActor.Structs {
    struct MyTestStruct: Codable {
        var test: String
    }
}

```

for this code i was getting this error

```swift
Circular referenceSourceKit
Test.swift(19, 12): Through reference here
Test.swift(19, 12): Through reference here
Test.swift(19, 12): Through reference here

```

```swift
Conformance of 'MyTestActor.Structs.MyTestStruct' to protocol 'Encodable' crosses into main actor-isolated code and can cause data racesSourceKitconformance-isolation
Test.swift(19, 22): Isolate this conformance to the main actor with '@MainActor'
Test.swift(19, 22): Turn data races into runtime errors with '@preconcurrency'
Test.swift(19, 22): Main actor-isolated instance method 'encode(to:)' cannot satisfy nonisolated requirement (Mana.MyTestActor.Structs.MyTestStruct.encode)

```

although what is funny.. if i change my code to this code, it suddenly is not throwing any error anymore, although i just removed the nesting of the structs.. why does this happen?

```swift
extension MyTestActor {
    struct Structs {}
}

extension MyTestActor {
    struct MyTestStruct: Codable {
        var test: String
    }
}

```

---

<div class="post-metadata">

**Author:** ![gwendal.roue](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/gwendal.roue/32/13992_2.png) [@gwendal.roue](https://forums.swift.org/u/gwendal.roue)\
**Post date:** [June 27, 2025, 7:11pm UTC](https://forums.swift.org/t/cycle-reference-since-changing-to-default-actor-isolation-main-actor-in-nested-structs/80745/2 "2025-06-27T19:11:39Z")

</div>

This was likely reported in [Codable conformance throws Circular reference compile error when default isolation is enabled · Issue #82200 · swiftlang/swift · GitHub](https://github.com/swiftlang/swift/issues/82200), which is closed. If Xcode 26 beta 2 still has the issue, you can wait for beta 3 or 4 (we never know), or look closely and open a new issue if you think that your scenario is distinct from the one that was originally reported.

---

<div class="post-metadata">

**Author:** ![Seyden](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/seyden/32/41672_2.png) [@Seyden](https://forums.swift.org/u/Seyden)\
**Post date:** [June 27, 2025, 7:40pm UTC](https://forums.swift.org/t/cycle-reference-since-changing-to-default-actor-isolation-main-actor-in-nested-structs/80745/3 "2025-06-27T19:40:20Z")

</div>

Thanks, i tried it with XCode 26 Beta 2 but the issue is still there. I will open a new issue and maybe someone will tell me if i do something wrong or if its a bug 🙂 Thank you

---

<div class="post-metadata">

**Author:** ![Slava\_Pestov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/slava_pestov/32/30204_2.png) [@Slava\_Pestov](https://forums.swift.org/u/Slava_Pestov)\
**Post date:** [June 27, 2025, 8:19pm UTC](https://forums.swift.org/t/cycle-reference-since-changing-to-default-actor-isolation-main-actor-in-nested-structs/80745/4 "2025-06-27T20:19:22Z")

</div>

The fix is not in Xcode 26 beta 2, but it is in the 6.2 development snapshots on [swift.org](http://swift.org).
