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-2386] Error when adding static stored properties to Objective-C classes in extensions #44993

Closed
ahoppen opened this issue Aug 18, 2016 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@ahoppen
Copy link
Contributor

ahoppen commented Aug 18, 2016

Previous ID SR-2386
Radar None
Original Reporter @ahoppen
Type Bug
Status Resolved
Resolution Duplicate
Environment

Swift 2.2: 7.3.1 (7D1014)
Swift 3.0: Xcode 8.0 beta 6 (8S201h), master ae69ffb

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 5547fd5a3e611ef2418c99e0d944a6fc

duplicates:

  • SR-993 Objc class extensions don't support stored type properties, error message is confusing

Issue Description:

When adding a static stored property to an Objective-C classes in an extension, the compiler fails with the error message A declaration cannot be both 'final' and 'dynamic' which is not associated with any source location.

import Foundation

public class TestClass: NSObject {
}

extension TestClass {
  class let x = 5
}

If TestClass does not inherit from NSObject (and is hence not @objc) the code compiles fine.

If you write class let x = 5 instead of static let x = 5, the compiler fails with the error message Class stored properties not supported in classes; did you mean 'static'? suggesting the static keyword.

If adding static stored properties to @objc classes is not supported in extensions, we should produce a diagnostic that clearly points out the issue (including a source location).

@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
Projects
None yet
Development

No branches or pull requests

1 participant