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
Swift Ver. 3.0.2
md5: 09af3d026b3ca16963a2c72d8d00ef63
is duplicated by:
relates to:
Issue Description:
protocol Parent {} protocol A: Parent {} protocol B: Parent {} struct Foo: A {} class ClassA { func foo<T: A>(param: T) { print("A") } } class ClassB: ClassA { override func foo<T: A>(param: T) { print("A") } override func foo<T: B>(param: T) { print("B") } } let foo = Foo() let classB = ClassB() classB.foo(param: foo)
Expected result: "A" will be printed Actual result: "B" is printed
If we remove foo<T: A> overload compiler will complain argument type 'Foo' does not conform to expected type 'B'.
foo<T: A>
argument type 'Foo' does not conform to expected type 'B'
The text was updated successfully, but these errors were encountered:
This is "fixed" in Swift 3.1:
<stdin>:19:19: error: 'foo(param:)' has already been overridden override func foo<T: B>(param: T) { ^ <stdin>:15:19: note: 'foo(param:)' previously overridden here override func foo<T: A>(param: T) { ^
but if you take out the first override the compiler incorrectly accepts the code:
protocol Parent {} protocol A: Parent {} protocol B: Parent {} class ClassA { func foo<T: A>(param: T) { print("A") } } class ClassB: ClassA { override func foo<T: B>(param: T) { print("B") } }
Sorry, something went wrong.
@swift-ci create
#24484
slavapestov
No branches or pull requests
Environment
Swift Ver. 3.0.2
Additional Detail from JIRA
md5: 09af3d026b3ca16963a2c72d8d00ef63
is duplicated by:
relates to:
Issue Description:
Expected result: "A" will be printed
Actual result: "B" is printed
If we remove
foo<T: A>
overload compiler will complainargument type 'Foo' does not conform to expected type 'B'
.The text was updated successfully, but these errors were encountered: