-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
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.
Description
| Previous ID | SR-7495 |
| Radar | None |
| Original Reporter | domas (JIRA User) |
| Type | Bug |
| Status | Resolved |
| Resolution | Won't Do |
Environment
Xcode 9.3 (9E145)
Swift version 4.1 (swiftlang-902.0.48 clang-902.0.37.1)
Target: x86_64-apple-darwin17.5.0
macOS 10.13.4 (17E199)
Additional Detail from JIRA
| Votes | 0 |
| Component/s | |
| Labels | Bug |
| Assignee | None |
| Priority | Medium |
md5: 723173a88503687fffbeb4aa3a8c991c
Issue Description:
Trying to check if type conforms to a protocol in an indirect way fails.
protocol P {}
struct T: P {}
// 0. Check with `is`
T.self is P.Type // true
// 1. Direct conformance check
func isOfTypeP(_ t: Any.Type) -> Bool {
P.self // __lldb_expr_67.P.Protocol
return t is P.Type
}
isOfTypeP(T.self) // true
// 2. Indirect conformance check
func isType<G>(_ t: Any.Type, subtypeOf _: G.Type) -> Bool {
G.self // __lldb_expr_67.P.Protocol
return t is G.Type
}
isType(T.self, subtypeOf: P.self) // false!!Checking the superclass in the same way works as expected.
class S {}
class C: S {}
isType(C.self, subtypeOf: S.self) // trueMetadata
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.