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-10603] Overloading Overriden Method By Generic Constraint-ness Causes Compiler Error #53003

Closed
swift-ci opened this issue May 2, 2019 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented May 2, 2019

Previous ID SR-10603
Radar None
Original Reporter trevorthoele (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 0cbd26e948dad416f341c710f7c17100

duplicates:

  • SR-4206 Override checking does not properly enforce requirements

relates to:

  • SR-4206 Override checking does not properly enforce requirements

Issue Description:

Overloading a method in a derived class that is the same type of signature from a base class with different generic constraints causes the compiler to think they are the same signature. I would expect overloads to be able to be created in the derived class with the same signature and different generic constraints.

protocol P {}


class Base {
    func f<T>(_ type: T.Type) {}
}


class Derived : Base {
    override func f<T>(_ type: T.Type) {}
    // 'f' has already been overriden
    func f<T>(_ type: T.Type) where T : P {}
}
@belkadan
Copy link
Contributor

belkadan commented May 2, 2019

I thought we already had a bug for this but I can't find it now. cc @slavapestov, @hamishknight

@slavapestov
Copy link
Member

It's the exact bug you related this one to (we're not comparing the generic signatures at all, so if constraints are too narrow we get a miscompile; if they're too broad we get false positives like this example)

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

No branches or pull requests

3 participants