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-2885] Optional protocol method does not follow Swift 3 method name translation rule in subclass #45479

Closed
swift-ci opened this issue Oct 7, 2016 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself runtime The Swift Runtime

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Oct 7, 2016

Previous ID SR-2885
Radar None
Original Reporter thanhpham (JIRA User)
Type Bug
Status Closed
Resolution Duplicate
Environment

Swift 3, Xcode 8, iOS 10, iPhone 7 Simulator

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

md5: 763008d989d0c4a789fb56ced5ca3814

duplicates:

  • SR-2817 selector mismatch with obj-c delegates + extensions

Issue Description:

With the change described in SE-0005, some obvious words in Objective-C method names are now omitted when translating to Swift 3. However, in the case below, the method name translation does not work correctly making the obvious words NOT get omitted.

import UIKit

class SuperClass: NSObject, UICollectionViewDelegate {}
class SubClass: SuperClass {
  func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
    print("NEW TRANSLATION")
  }

  func collectionView(_ collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: IndexPath) {
    print("OLD TRANSLATION")
  } 
}

SuperClass is declared to be conformed to UICollectionViewDelegate protocol but does not implement any method from the protocol. SubClass is inherited from SuperClass and actually implements an optional method defined in UICollectionViewDelegate.
Now assign an instance of SubClass as the delegate of a UICollectionView, the string "OLD TRANSLATION" will be printed when the delegate method is called while users would expect "NEW TRANSLATION" instead. That means Swift 3 method name translation rule does not work correctly in this case.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Oct 7, 2016

Comment by Stuart Foulston (JIRA)

I'm wondering if this could be related to SR-2817?

@swift-ci
Copy link
Collaborator Author

swift-ci commented Oct 7, 2016

Comment by Pham Minh Thanh (JIRA)

Hey, you are the one asked it on Stack Overflow. So yes, they are the same. Sorry for making a dupe.

@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 runtime The Swift Runtime
Projects
None yet
Development

No branches or pull requests

1 participant