Skip to content

[SR-2427] Cannot override generic methods in generic subclass #45032

@DeFrenZ

Description

@DeFrenZ
Previous ID SR-2427
Radar rdar://problem/18560464
Original Reporter @DeFrenZ
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug
Assignee @slavapestov
Priority Medium

md5: 947d76ec0225e4dfba0192393a7153ce

is duplicated by:

  • SR-2780 Cannot override generic method in generic subclass
  • SR-2998 Generic methods with type constraints are inconsistently overridable

relates to:

  • SR-2721 Cannot override generic methods in non-generic subclass

Issue Description:

In the following snippet I can't make `Bar.foo` an `override`, or it won't compile. And if I don't when I call it it will of course complain about ambiguousity... making the subclass or the method non-generic would make things o-kay, but the case with both seems to be not working correctly.

public class Foo {
    public func foo <T> (_ foo: T) {
        print("Foo.foo")
    }
}

public class Bar<B>: Foo {
    // can't make it an `override`
    public func foo <T> (_ foo: T) {
        print("Bar.foo")
    }
}

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itself

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions