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-6944] [Xcode 9.3b2] Objective-C method provided by getter does not match the requirement's selector #49492

Closed
swift-ci opened this issue Feb 7, 2018 · 13 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 4.1

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Feb 7, 2018

Previous ID SR-6944
Radar rdar://problem/37363245
Original Reporter amro (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode 9.3 beta 2

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

md5: 1e35181689a6a6f0a82d0fb4a58a7109

Issue Description:

Filed in response to this Twitter conversation

Objective-C method 'selfThreadTweet' provided by getter for 'displayAsSelfThreadTweet' does not match the requirement's selector ('displayAsSelfThreadTweet')

Attempting to define the short name (selfThreadTweet) results in this error:

'selfThreadTweet' has been renamed to 'displayAsSelfThreadTweet'

and provides a Fix-it to do so.

This seems to be an error in our code, but apparently this should not have been fixed in 9.3b2.

@belkadan
Copy link
Contributor

belkadan commented Feb 7, 2018

@swift-ci create

@belkadan
Copy link
Contributor

belkadan commented Feb 7, 2018

Any chance you can share the full definition of both the protocol and the class? Just want to make sure we fix the same thing you're seeing.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Feb 7, 2018

Comment by Amro Mousa (JIRA)

I'm not in a position to do that, but I'll do my best to reproduce the issue in a sample project today and attach it to this ticket.

@belkadan
Copy link
Contributor

belkadan commented Feb 7, 2018

My initial diagnosis was wrong; apparently the getter name is preferred (probably because of the common "isFoo" with a property name of "foo", where "isFoo" better matches the Swift conventions). But this code works in both master and 4.0:

class TestLong: Foo {
  var displayAsSelfThreadTweet: Bool { return true }
}

So something else funny is going on.

@belkadan
Copy link
Contributor

belkadan commented Feb 7, 2018

Also seems to work in Swift 3.1.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Feb 7, 2018

Comment by Amro Mousa (JIRA)

Thanks @belkadan. This is working for me in a sample project as well. I'll try to figure out what's different in our larger project. This is code that will be going away in the near future, but I'd still like to understand what's happening.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Feb 7, 2018

Comment by Amro Mousa (JIRA)

No luck narrowing this down to a sample project. I'll spend more time on that tomorrow.

@belkadan
Copy link
Contributor

belkadan commented Feb 9, 2018

Sorry, I just can't get this to fail locally. Going to have to send it back. :-(

@belkadan
Copy link
Contributor

Good news: an Apple-internal client ran into this too. I don't think the fix'll make 4.1, but at least your workaround should be safe.

@swift-ci
Copy link
Collaborator Author

Comment by Amro Mousa (JIRA)

That's great news! Thanks @belkadan.

@belkadan
Copy link
Contributor

Reduced:

@import Foundation;

@protocol TestProto
@property (nonatomic, readonly, getter=isFoo) BOOL foo;
@end
class Test: TestProto {
  var isFoo: Bool { return false }
}
protocol HasAssoc {
  associatedtype Assoc: TestProto
}

struct Impl: HasAssoc {
  typealias Assoc = Test
}

The error is emitted when compiling b.swift.

@belkadan
Copy link
Contributor

#14794

Unfortunately probably not worth pulling into 4.1 at this point, since there is a workaround.

@belkadan
Copy link
Contributor

belkadan commented Apr 2, 2018

Took me longer than expected to come to a viable solution, but it's in now! You should be able to test with a master snapshot in the next few days.

@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 regression swift 4.1
Projects
None yet
Development

No branches or pull requests

3 participants