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-11073] Generic subclass does not respond to selector if conforming Objective-C protocol #53465

Closed
swift-ci opened this issue Jul 5, 2019 · 0 comments
Labels
attributes Feature: Declaration and type attributes bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances duplicate Resolution: Duplicates another issue @objc Feature → attributes: The @objc attribute objective-c interop Feature: Interoperability with Objective-C regression swift 5.0 type checker Area → compiler: Semantic analysis unexpected behavior Bug: Unexpected behavior or incorrect output whole module optimization only Flag: An issue whose reproduction requires whole module optimization

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 5, 2019

Previous ID SR-11073
Radar None
Original Reporter andoku901 (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

XCode 10.2.1 default toolchain

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

md5: 6d8b5869344f293ba1395c7797c79f52

duplicates:

Issue Description:

Write the following code in a Swift file:

class SwiftVC<View: UIView>: UIViewController, UICollectionViewDelegateFlowLayout {
    var rootView: View? {
        return self.view as? View
    }
}

final class SubSwiftVC: SwiftVC<UIView> {
    func collectionView(_ collectionView: UICollectionView,
                        layout collectionViewLayout: UICollectionViewLayout,
                        sizeForItemAt indexPath: IndexPath) -> CGSize
    {
        return .zero
    }
}

class SwiftVCAdaptor: NSObject {
    @objc func vc() -> UIViewController {
        return SubSwiftVC()
    }
}

Then write in an Objective-C file the next:

    UIViewController *vc = [[SwiftVCAdaptor new] vc];
    if ([vc respondsToSelector:@selector(collectionView:layout:sizeForItemAtIndexPath:)]) {
        // This is not executed.
    }

This behavior can be fixed by declaring collectionView:layout:sizeForItemAt: method in SwiftVC and overriding it in SubSwiftVC.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added duplicate Resolution: Duplicates another issue compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis conformances Feature → protocol: protocol conformances attributes Feature: Declaration and type attributes objective-c interop Feature: Interoperability with Objective-C unexpected behavior Bug: Unexpected behavior or incorrect output @objc Feature → attributes: The @objc attribute regression whole module optimization only Flag: An issue whose reproduction requires whole module optimization swift 5.0 labels Jan 19, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
attributes Feature: Declaration and type attributes bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances duplicate Resolution: Duplicates another issue @objc Feature → attributes: The @objc attribute objective-c interop Feature: Interoperability with Objective-C regression swift 5.0 type checker Area → compiler: Semantic analysis unexpected behavior Bug: Unexpected behavior or incorrect output whole module optimization only Flag: An issue whose reproduction requires whole module optimization
Projects
None yet
Development

No branches or pull requests

2 participants