You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
extension VersionedProtocol where Version == Version0x0x0 {
typealias Foo = Int
}
extension VersionedProtocol where Version == Version0x0x1 {
typealias Foo = String
}
// I expected the errors in 3 and 4
// -— Example 3 --— // invalid redeclaration foo()
func foo() {}
func foo() {}
// -— Example 4 -— // invalid redeclaration Foo
typealias Foo = Int
typealias Foo = String
In example 3 and 4, I expect invalid redeclaration (specifically: invalid redeclaration foo() and invalid redeclaration Foo respectively), that makes sense to me. But why don't I get an invalid redeclaration in example 1 if I get an invalid redeclaration in example 2.
The text was updated successfully, but these errors were encountered:
We allow overloading functions on generic requirements, but the rules for non-function declarations like nested types and properties are more restrictive.
Environment
Latest Mac update, Swift Version 4.1
Additional Detail from JIRA
md5: df87332af6d8eeadda1968dc3c7be7d0
Issue Description:
I was exploring some things with the swift language and came across this example:
// Swift Version: 4.1
// ---— Example 1 -— // No invalid redeclaration error
// I expected this
protocol VersionedProtocol {
associatedtype Version : VersionType
}
protocol VersionType {}
enum Version0x0x0 : VersionType {}
enum Version0x0x1: VersionType {}
extension VersionedProtocol where Version == Version0x0x0 {
func foo() {}
}
extension VersionedProtocol where Version == Version0x0x1 {
func foo() {}
}
// -— Example 2 --— // invalid redeclaration Foo
// I did not expect this
protocol VersionedProtocol {
associatedtype Version : VersionType
}
protocol VersionType {}
enum Version0x0x0 : VersionType {}
enum Version0x0x1: VersionType {}
extension VersionedProtocol where Version == Version0x0x0 {
typealias Foo = Int
}
extension VersionedProtocol where Version == Version0x0x1 {
typealias Foo = String
}
// I expected the errors in 3 and 4
// -— Example 3 --— // invalid redeclaration foo()
func foo() {}
func foo() {}
// -— Example 4 -— // invalid redeclaration Foo
typealias Foo = Int
typealias Foo = String
In example 3 and 4, I expect invalid redeclaration (specifically: invalid redeclaration foo() and invalid redeclaration Foo respectively), that makes sense to me. But why don't I get an invalid redeclaration in example 1 if I get an invalid redeclaration in example 2.
The text was updated successfully, but these errors were encountered: