Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-993] Objc class extensions don't support stored type properties, error message is confusing #43605

Closed
an0 mannequin opened this issue Mar 19, 2016 · 3 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers

Comments

@an0
Copy link
Mannequin

an0 mannequin commented Mar 19, 2016

Previous ID SR-993
Radar radar://20512544
Original Reporter @an0
Type Bug
Status Resolved
Resolution Done
Environment

Swift 3 in Xcode 8.0 beta 3

Additional Detail from JIRA
Votes 2
Component/s Compiler
Labels Bug, DiagnosticsQoI, StarterBug
Assignee None
Priority Medium

md5: d9305dc29182276d2baf4b7f5081f44f

is duplicated by:

  • SR-2386 Error when adding static stored properties to Objective-C classes in extensions

Issue Description:

I guess currently ObjC class extensions don't support stored type properties. But the error message is very confusing and without any location information:

a declaration cannot be both 'final' and 'dynamic'

import Foundation

extension Int {
    // Swift extensions support stored type properties.
    static let a = 1
}

class Foo: NSObject {}

extension Foo {
    static let a = 1
}
@an0
Copy link
Mannequin Author

an0 mannequin commented Aug 3, 2016

From the release notes of Xcode 8 beta 4 I learned that it is the same bug:

When using static in an extension of an Objective-C class, the compiler may produce the error "a declaration cannot be both 'final' and ‘dynamic'." This error is a consequence of Swift using dynamic to implement members exposed to Objective-C in extensions, and static being equivalent to class final when used within a class or extension of a class. In some cases, this error will not have the correct location information.

Workaround: Use class instead of static (making the method or property non-final) or add @nonobjc (making the method or property non-dynamic and hiding it from Objective-C). (20512544)

Someone please link it to that bug. Thanks.

@DougGregor
Copy link
Member

#4874

@DougGregor
Copy link
Member

ca59a40

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant