Mysterious “Will never be executed” warning


(Rudolf Adamkovič) #1

I'm trying to understand "Will never be executed" warning here:

protocol FatalErrorReporterInterface {

    func fail(_ message: String) -> Never

}

final class FatalErrorReporter: FatalErrorReporterInterface {

    // This line emits "Will never be executed" warning
    func fail(_ message: String) -> Never {
        fatalError(message)
    }

}
Yet another compiler bug?

https://stackoverflow.com/questions/44332850/mysterious-will-never-be-executed-warning

R+


(Jordan Rose) #2

Sure looks like one to me. In particular, it looks like SR-2729 <https://bugs.swift.org/browse/SR-2729>.

(I suspect this is because calling the method through the protocol generates a bit of wrapper code that then calls the original method; that wrapper code doesn’t have a location of its own.)

Sorry for the trouble,
Jordan

···

On Jun 2, 2017, at 08:48, Rudolf Adamkovič via swift-users <swift-users@swift.org> wrote:

I'm trying to understand "Will never be executed" warning here:

protocol FatalErrorReporterInterface {

    func fail(_ message: String) -> Never

}

final class FatalErrorReporter: FatalErrorReporterInterface {

    // This line emits "Will never be executed" warning
    func fail(_ message: String) -> Never {
        fatalError(message)
    }

}
Yet another compiler bug?

https://stackoverflow.com/questions/44332850/mysterious-will-never-be-executed-warning

R+
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users