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-11416] Protocol behavior in Swift 5, regression? #53817

Closed
swift-ci opened this issue Sep 4, 2019 · 2 comments
Closed

[SR-11416] Protocol behavior in Swift 5, regression? #53817

swift-ci opened this issue Sep 4, 2019 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. regression swift 5.0

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Sep 4, 2019

Previous ID SR-11416
Radar None
Original Reporter netbe (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

macOS 10.14.6

Swift 5.0

Xcode 10.3

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

md5: 5993cd337986f4dc92c51bc4e0914327

duplicates:

  • SR-10285 Subclass of a class that conforms to a protocol and extends NSObject is not instantiate correctly

Issue Description:

The following code does not behave as before in Swift 4.2, see commented output

protocol Foo {
  init()
  func configureBar()
}

extension Foo {
 
 init(toto: String) {
   self.init()
   self.configureBar()
 }
}

class Toto: NSObject, Foo {
 
 override required init() {}
 
 func configureBar() {
   print("toto")
 }
}

class SubToto: Toto {
 override func configureBar() {
   print("tata")
 }
}

SubToto(toto: "Hello")
// toto in swift 5
// tata in swift 4
@AliSoftware
Copy link
Contributor

netbe (JIRA User) Seems fixed in Swift 5.1 already though, at least as tested with Xcode 11b6?

$ DEVELOPER_DIR=/Applications/Xcode-10.2.1.app swift --version
Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)
Target: x86_64-apple-darwin18.7.0

$ DEVELOPER_DIR=/Applications/Xcode-10.2.1.app swift ~/Desktop/sr-11416.swift
/Users/olivier.halligon/Desktop/sr-11416.swift:31:1: warning: result of 'Foo' initializer is unused
SubToto(toto: "Hello")
^      ~~~~~~~~~~~~~~~
toto
$ DEVELOPER_DIR=/Applications/Xcode-10.3.app swift --version
Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)
Target: x86_64-apple-darwin18.7.0

$ DEVELOPER_DIR=/Applications/Xcode-10.3.app swift ~/Desktop/sr-11416.swift
/Users/olivier.halligon/Desktop/sr-11416.swift:31:1: warning: result of 'Foo' initializer is unused
SubToto(toto: "Hello")
^      ~~~~~~~~~~~~~~~
toto
$ DEVELOPER_DIR=/Applications/Xcode-11b6.app swift --version
Apple Swift version 5.1 (swiftlang-1100.0.270.6 clang-1100.0.32.1)
Target: x86_64-apple-darwin18.7.0

$ DEVELOPER_DIR=/Applications/Xcode-11b6.app swift ~/Desktop/sr-11416.swift
/Users/olivier.halligon/Desktop/sr-11416.swift:31:1: warning: result of 'Foo' initializer is unused
SubToto(toto: "Hello")
^      ~~~~~~~~~~~~~~~
tata

@belkadan
Copy link
Contributor

belkadan commented Sep 4, 2019

Fixed in Swift 5.1!

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

No branches or pull requests

4 participants