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 Version 11.1 (11A1027)
Apple Swift version 5.1 (swiftlang-1100.0.270.13 clang-1100.0.33.7)
Additional Detail from JIRA
Votes
1
Component/s
Compiler
Labels
Bug
Assignee
None
Priority
Medium
md5: 7ff2d04eb9e0e0bae53cab422092055a
Issue Description:
Next code can make different function calling from same type.
If passing the Type from generics, if the Type apply to associatedtype, then protocol witness table create different way.
protocolA {}
protocolP {
associatedtypeTvarvalue: T { get }
functIsA() -> Bool
}
extensionP {
functIsA() -> Bool {
false
}
}
extensionPwhereT: A {
functIsA() -> Bool {
true
}
}
structX: A {}
structAnyP<T>: P {
varvalue: T
}
funccheck(x: X) {
print(AnyP(value: x).tIsA())
}
funccheck2<X2>(x: X2) {
print(AnyP(value: x).tIsA())
}
check(x: X()) // truecheck2(x: X()) // false
The text was updated successfully, but these errors were encountered:
This is behaving as designed, although one could imagine other designs. Protocol conformances select the most specific function to call that is guaranteed to work for all specializations of the type. Because AnyP's T argument is not guaranteed to conform to A (it's not a requirement), that means the conformance has to pick the tIsA that returns false. When we have full type information, we can pick something more specific.
Environment
Xcode Version 11.1 (11A1027)
Apple Swift version 5.1 (swiftlang-1100.0.270.13 clang-1100.0.33.7)
Additional Detail from JIRA
md5: 7ff2d04eb9e0e0bae53cab422092055a
Issue Description:
Next code can make different function calling from same type.
If passing the Type from generics, if the Type apply to associatedtype, then protocol witness table create different way.
The text was updated successfully, but these errors were encountered: