swiftlang/swift

[SR-7301] Bad fixit suggested for protocol extension implementation for inherited objc protocol

オープン

#49,849 opened on 2018/03/28

 (11 件のコメント) (0 件のリアクション) (0 人の担当者)Swift (10,719 件のフォーク)batch import
bugcompilergood first issue

Repository metrics

Stars
 (69,989 個のスター)
PR merge metrics
 (平均マージ 8d 17h) (30d で 510 merged PRs)

説明

Previous ID SR-7301
Radar None
Original Reporter kdawgwilk (JIRA User)
Type Bug

Attachment: Download

Xcode 9.2

Swift 4

macOS 10.13.3

Votes 0
Component/s Compiler
Labels Bug, StarterBug
Assignee None
Priority Medium

md5: f483fe309b1876278257725a1dc2b1b5

relates to:

  • SR-3349 @objc methods cannot be contained in protocol extensions

Issue Description:

I have the following code that has a compiler error

@objc protocol IntroAnimationController: UIViewControllerAnimatedTransitioning {
    func frame(for view: UIView, fromView: UIView) -> CGRect
    func animations(fromView: UIView, toView: UIView) -> () -> Void
}

extension IntroAnimationController {
    func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
        return 0.20
    }
}

The error says:

![](Screen Shot 2018-03-28 at 3.47.33 PM.png)

and includes a fixit that that turns my code into this:

extension IntroAnimationController {
    @objc(transitionDuration:) func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
        return 0.20
    }
}

And then gives me these two wonderful new errors:

![](Screen Shot 2018-03-28 at 3.46.32 PM.png)

None of the fixits are helpful and the error message does not give me any clue why I can't do this

コントリビューターガイド