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-10198] Cannot override more than one superclass declaration #52598

Closed
swift-ci opened this issue Mar 27, 2019 · 4 comments
Closed

[SR-10198] Cannot override more than one superclass declaration #52598

swift-ci opened this issue Mar 27, 2019 · 4 comments
Assignees

Comments

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Mar 27, 2019

Previous ID SR-10198
Radar rdar://problem/49339618
Original Reporter nh7a (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @theblixguy
Priority Medium

md5: b648d70ee267e118a99dbd1f3d5ba85b

duplicates:

  • SR-4206 Override checking does not properly enforce requirements

relates to:

  • SR-10231 Overloading Overriden Method By Inout-ness Causes Compile Error

Issue Description:

It seems that subclass cannot override a superclass's method in the situation like below although there's an exact match and thus shouldn't be a problem.

class Foo {
  func a<T>(_ val: T) -> String { return "not equatable" }
  func a<T: Equatable>(_ val: T) -> String { return "equatable" }
}

class Bar: Foo {
  // these work like a charm
  func b<T>(_ val: T) -> String { return super.a(val) }
  func b<T: Equatable>(_ val: T) -> String { return super.a(val) }

  // "declaration 'a' cannot override more than one superclass declaration"
  override func a<T>(_ val: T) -> String { return super.a(val) }
  override func a<T: Equatable>(_ val: T) -> String { return super.a(val) }
}

let bar = Bar()
bar.b(1) // "equatable"
bar.b(Int.self) // "not equatable"
@slavapestov
Copy link
Member

@slavapestov slavapestov commented Apr 1, 2019

This is the same problem as SR-4206. We completely ignore the generic signature requirements when checking overrides. In SR-4206, we inappropriately make one method an override of another even though the base class method has fewer requirements; in this bug, we flag the method as overriding two methods when it really only overrides one, for the same reason.

@theblixguy
Copy link
Collaborator

@theblixguy theblixguy commented Aug 7, 2019

Reopened because the issue hasn't been fixed

@theblixguy
Copy link
Collaborator

@theblixguy theblixguy commented Aug 7, 2019

PR: #26536

@theblixguy
Copy link
Collaborator

@theblixguy theblixguy commented Aug 9, 2019

Fixed on master. Please verify using the next master snapshot!

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

No branches or pull requests

3 participants