A declaration cannot be both 'final' and 'dynamic' error in Swift 1.2

后端 未结 7 1352
Happy的楠姐
Happy的楠姐 2021-01-30 07:55

The declaration of value below

import Foundation

class AAA: NSObject {
    func test2() {
        self.dynamicType
    }
}
extension AAA {
    stat         


        
相关标签:
7条回答
  • 2021-01-30 08:34

    I just stumbled over the same issue with a different cause and would like to post it here for other people experiencing the same useless error message.

    A final class which overrides a computed variable defined in an extension also causes this error. It works for functions though and thus looks like a compiler bug.

    // at line 0: a declaration cannot be both 'final' and 'dynamic'
    
    import UIKit
    
    extension UIViewController {
        var test: Int { return 0 }
    }
    
    final class TestController: UIViewController {
        override var test: Int { return 1 }
    }
    
    0 讨论(0)
提交回复
热议问题