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
Xcode 9 beta 2, tried both default toolchain and dev snapshot 2017-06-03
Additional Detail from JIRA
Votes
0
Component/s
Compiler
Labels
Bug
Assignee
None
Priority
Medium
md5: fa37b4ccfbea6b9fbc48f07ee361235d
relates to:
SR-7217 Protocol composition with conflicting typealiases does not diagnose
SR-3793 Protocol extension cannot implement associated type
SR-5440 Typealias in constrained extension misinterprets the where clause
Issue Description:
protocol P {
associatedtype A
typealias B = Int
}
extension P where A == Bool {
typealias B = Float // Compiles, but should it?
}
extension P where A == Double {
typealias B = String // ERROR: Invalid redeclaration of `B`
}
// Note that Bool, Int, Float, Double and String can be any types; ie
// the topmost extension will always compile and the rest will not.
// Same behavior with generic typealiases.
// Should both compile (thus shadowing the default B) or should both be
// considered redeclarations?
// The same example but with a struct instead of a protocol consistently
// treats both as redeclarations:
struct S<A> {
typealias B = Int
}
extension S where A == Bool {
typealias B = Float // ERROR: Invalid redeclaration of `B`
}
extension S where A == Double {
typealias B = String // ERROR: Invalid redeclaration of `B`
}
The text was updated successfully, but these errors were encountered:
The typealias B existence in the protocol P declaration isn't necessary to reproduce this defect. I mean that the behavior is the same for the following declaration.
The most painful case is when you need to create two different extensions to confirm two different protocols that have associatedtype-s with the same name, and those protocols are in a third-party framework. To do it you should reimplement half of the project instead of use extension that exists especially to provide the ability to extend the program so easy. At this moment you think: Why didn't I build my system with classes based on OOP? Why did I use extensions?
Environment
Xcode 9 beta 2, tried both default toolchain and dev snapshot 2017-06-03
Additional Detail from JIRA
md5: fa37b4ccfbea6b9fbc48f07ee361235d
relates to:
Issue Description:
The text was updated successfully, but these errors were encountered: