-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itself
Description
| Previous ID | SR-3145 |
| Radar | None |
| Original Reporter | ellneal (JIRA User) |
| Type | Bug |
Environment
Swift 3.0.1 |
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug |
| Assignee | None |
| Priority | Medium |
md5: b543b9861b9acc9be7a5739c0a9e33f8
Issue Description:
I'm prefacing this by saying that I know this is an overly complicated example, but I think the compiler is wrong in saying that this is ambiguous.
class Root { }
protocol Generic {
associatedtype RootType: Root
var root: RootType { get }
}
extension Generic where Self: Root {
var root: Self {
return self
}
}
class Leaf: Root { }
protocol Specialised { }
extension Specialised where Self: Generic {
var root: Leaf {
get {
return Leaf()
}
}
}
class Implementation: Generic, Specialised {
// errors:
// Ambiguous inference of associated type 'RootType': 'Leaf' vs. 'Implementation'
// Matching requirement 'root' to this declaration inferred associated type to 'Leaf'
// Matching requirement 'root' to this declaration inferred associated type to 'Implementation'
}I believe that if Implementation also inherited from Root this would be ambiguous, but not in the current state (as far as I can tell).
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itself