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-11651] Extension of generic Obj-C type has confusing note about adding @objc #54062

Open
lilyball mannequin opened this issue Oct 22, 2019 · 1 comment
Open

[SR-11651] Extension of generic Obj-C type has confusing note about adding @objc #54062

lilyball mannequin opened this issue Oct 22, 2019 · 1 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

Comments

@lilyball
Copy link
Mannequin

lilyball mannequin commented Oct 22, 2019

Previous ID SR-11651
Radar None
Original Reporter @lilyball
Type Bug
Environment

Apple Swift version 5.1 (swiftlang-1100.0.270.13 clang-1100.0.33.7)
Target: x86_64-apple-darwin19.0.0

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

md5: dde1d9580e619da40b6eb95e607b880b

relates to:

  • SR-11652 Extension of generic Obj-C type with @objc method crashes the compiler

Issue Description:

When trying to extend a generic Obj-C type in Swift, adding a method produces an error:

import Foundation
extension NSHashTable {
    func foo(_ x: ObjectType) {}
}
foo.swift:3:10: error: extension of a generic Objective-C class cannot access the class's generic parameters at runtime
    func foo(_ x: ObjectType) {}
         ^
foo.swift:3:10: note: add '@objc' to allow uses of 'self' within the function body
    func foo(_ x: ObjectType) {}
         ^
    @objc 
foo.swift:3:10: note: generic parameter used here
    func foo(_ x: ObjectType) {}
         ^

In particular, the first "note" seems out of place as my function body is completely empty.

@lilyball
Copy link
Mannequin Author

lilyball mannequin commented Oct 22, 2019

Also see SR-11652 wherein adding the suggested @objc attribute produces a compiler crash.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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
Projects
None yet
Development

No branches or pull requests

0 participants