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-11011] Swift/Objective-C bridging error involving overriding class variable declared in the superclass's extension #53401

Open
swift-ci opened this issue Jun 25, 2019 · 1 comment
Labels
accepts invalid Bug: Accepts invalid 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 run-time crash Bug → crash: Swift code crashed during execution

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-11011
Radar None
Original Reporter wayne2046 (JIRA User)
Type Bug
Environment

Playground in Xcode 11.0 beta 7 (11M392r)

Apple Swift version 5.1 (swiftlang-1100.0.270.6 clang-1100.0.32.1)

Target: x86_64-apple-darwin18.7.0

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

md5: f3fd041566fa2bdc563e72dc413bbf43

Issue Description:

extension UIColor {
    @objc class var myGolden: UIColor {
        return self.init(red: 1.000, green: 0.894, blue: 0.541, alpha: 0.900)
    }
}
print(UIColor.myGolden)


class MyUIColor: UIColor {
    override class var myGolden: UIColor {
        return super.init(red: 1.000, green: 0.894, blue: 0.541, alpha: 0.750)
    }
}
print(MyUIColor.myGolden)

The last line triggers a crash:

"libc++abi.dylib: terminating with uncaught exception of type NSException"

Inside of a class function/computed property, self and super should refer to the type of the class/struct, so in this case self.init and super.init should be equivalent to UIColor.init. Moreover, trying out an equivalent code but using only pure Swift classes, it all works fine.

@belkadan
Copy link
Contributor

Computed properties appear on subclasses too, so self.init means "make the dynamic type for this thing" and super.init should be disallowed.

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepts invalid Bug: Accepts invalid 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 run-time crash Bug → crash: Swift code crashed during execution
Projects
None yet
Development

No branches or pull requests

3 participants