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-5349] Can not extend Objective-c generics in Swift 4 #47923

Closed
swift-ci opened this issue Jul 1, 2017 · 7 comments
Closed

[SR-5349] Can not extend Objective-c generics in Swift 4 #47923

swift-ci opened this issue Jul 1, 2017 · 7 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software regression swift 4.0

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 1, 2017

Previous ID SR-5349
Radar rdar://problem/33108765
Original Reporter Calimari328 (JIRA User)
Type Bug
Status Closed
Resolution Cannot Reproduce
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.0Regression, CompilerCrash
Assignee None
Priority Medium

md5: 171eee9cedd95064bf9af4b65106217b

Issue Description:

I am using swift 4 running Xcode 9 beta 2.
And the compiler throws a segmentation fault for the following code

// Objective -c
@interface NSBox <__covariant T: id> : NSObject
@property T value;
@end

@implementation NSBox
@end
// Swift 
extension NSBox {} //<-- segmentation fault for an empty extension.

update July 4, 2017

There appears to be a workaround for this issue. The seg fault seems to happen if the Objective-c implementation and the swift extension exist in the same module, but it works without an issue if they are in separate ones as described here

Apparently if the Objective-c implementation is moved to a framework (i.e. Abc.framework), we can make a swift extension in a separate framework (i.e. Abc_extensions.framework) where Abc_extensions depends on Abc.framework.

It compiles and we get to add type specific methods.

extension NSBox where T == NSChocolates {
   public func life() {  }
}
@belkadan
Copy link
Contributor

belkadan commented Jul 3, 2017

There is no Xcode 9 beta 4. Did you mean beta 3?

@belkadan
Copy link
Contributor

belkadan commented Jul 3, 2017

@swift-ci create

@belkadan
Copy link
Contributor

belkadan commented Jul 3, 2017

Heh, and I hit "3" instead of "2" myself.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jul 4, 2017

Comment by Derrick Ho (JIRA)

Wow, not sure how I hit 4 instead of 2! Maybe I was thinking of July 4th. Heh. You got me excited that beta 3 came out, but alas it isn't time yet.

@swift-ci
Copy link
Collaborator Author

Comment by Graydon Hoare (JIRA)

Attempted to reproduce but unable; could you attach a project showing the arrangement that causes the fault?

@swift-ci
Copy link
Collaborator Author

Comment by Derrick Ho (JIRA)

The strange thing is that at the time I wrote the bug report it was segfaulting every time the swift extension existed. However a few days afterward, I tried recreating this in a new project. I was unable to do so. My guess is that there is something else provoking sag fault. I'll try to attach a project with the bug if possible

@swift-ci
Copy link
Collaborator Author

Comment by Derrick Ho (JIRA)

I can't figure out how to make the issue happen anymore, so I shall close this issue

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 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 crash Bug: A crash, i.e., an abnormal termination of software regression swift 4.0
Projects
None yet
Development

No branches or pull requests

3 participants