# Swift 6 (from Xcode 16b5), overridden function and isolation

**URL:** <https://forums.swift.org/t/swift-6-from-xcode-16b5-overridden-function-and-isolation/73862>\
**Category:** Using Swift\
**Tags:** override, isolated, swift-6\
**Created:** [August 9, 2024, 9:46am UTC](https://forums.swift.org/t/swift-6-from-xcode-16b5-overridden-function-and-isolation/73862 "2024-08-09T09:46:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andyj-at-aspin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/andyj-at-aspin/32/18552_2.png) [@andyj-at-aspin](https://forums.swift.org/u/andyj-at-aspin)\
**Post date:** [August 9, 2024, 9:46am UTC](https://forums.swift.org/t/swift-6-from-xcode-16b5-overridden-function-and-isolation/73862/1 "2024-08-09T09:46:57Z")

</div>

Has the isolation of override functions been changed with the latest beta release? The following two code snippets produce 1 failure to compile and 2 warnings. Earlier beta's had no issue with either snippet:

```swift
import Foundation
import UIKit

@MainActor class TestObject: NSObject {
    
    let testView = UIView(frame: .zero)
    
    private func doSomething() {
        
    }
    
    override init() {
        // [ERROR] Property 'self.testView' not initialised at super.init call 

        super.init()    
        
         // [WARNING] Call to main actor-isolated instance method 'doSomething()' in a synchronous nonisolated context; this is an error in the Swift 6 language mode

        doSomething()
    }
}

```

and

```swift
import Foundation
import UIKit

class TestListCell: UICollectionViewCell {
    
    private func doSomething() {
        
    }
    
    override func awakeFromNib() {

        // [WARNING] Call to main actor-isolated instance method 'doSomething()' in a synchronous nonisolated context; this is an error in the Swift 6 language mode

        doSomething()
    }    
}

```

(Compiling with complete concurrency checking but with the swift language mode set to 5)

---

<div class="post-metadata">

**Author:** ![vns](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/vns/32/37396_2.png) [@vns](https://forums.swift.org/u/vns)\
**Post date:** [August 9, 2024, 9:59am UTC](https://forums.swift.org/t/swift-6-from-xcode-16b5-overridden-function-and-isolation/73862/2 "2024-08-09T09:59:37Z")

</div>

Currently the simples solution to roll back to beta 4 and wait for 6th:

> [@Swift Concurrency In Real Apps](https://forums.swift.org/t/swift-concurrency-in-real-apps/73790/3):
>
> I hear your feedback, but this particular issue: is a regression in Xcode 16 Beta 5 that's fixed by [[6.0][Concurrency] Implement a narrow carve out in the isolation override checking for `NSObject.init()`. by hborla · Pull Request #75749 · swiftlang/swift · GitHub](https://github.com/swiftlang/swift/pull/75749).

---

<div class="post-metadata">

**Author:** ![hborla](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/hborla/32/27563_2.png) [@hborla](https://forums.swift.org/u/hborla)\
**Post date:** [August 9, 2024, 8:37pm UTC](https://forums.swift.org/t/swift-6-from-xcode-16b5-overridden-function-and-isolation/73862/3 "2024-08-09T20:37:19Z")

</div>

To be clear, my fix is only for subclassing `NSObject.init()` because to experience a data race, you'd need to call the subclass override dynamically through an `NSObject` metatype, which I think is rare (or impossible?). It is correct to get an error when trying to override a nonisolated superclass method in a subclass that adds actor isolation, and that was already the case for this pattern written purely in Swift. If you believe that a superclass method from an Apple framework you're using is missing an annotation like `@MainActor`, please report the issue via Apple Feedback Assistant.
