File tree Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -2905,10 +2905,13 @@ ProtocolDecl::getInheritedProtocols() const {
2905
2905
// Only protocols can appear in the inheritance clause
2906
2906
// of a protocol -- anything else should get diagnosed
2907
2907
// elsewhere.
2908
- if (auto *protoTy = type->getAs <ProtocolType>()) {
2909
- auto *protoDecl = protoTy->getDecl ();
2910
- if (known.insert (protoDecl).second )
2911
- result.push_back (protoDecl);
2908
+ if (type->isExistentialType ()) {
2909
+ auto layout = type->getExistentialLayout ();
2910
+ for (auto protoTy : layout.getProtocols ()) {
2911
+ auto *protoDecl = protoTy->getDecl ();
2912
+ if (known.insert (protoDecl).second )
2913
+ result.push_back (protoDecl);
2914
+ }
2912
2915
}
2913
2916
}
2914
2917
}
Original file line number Diff line number Diff line change
1
+ public protocol Critter {
2
+ associatedtype Fur
3
+ }
4
+ public protocol Pet { }
5
+
6
+ public typealias Cat = Critter & Pet
7
+
8
+ public protocol Kitten : Cat { }
9
+
10
+ extension Kitten {
11
+ public func pet( ) -> Fur {
12
+ while true { }
13
+ }
14
+ }
15
+
16
+ public final class Meow < Purrs> : Kitten {
17
+ public typealias Fur = Purrs
18
+ }
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -typecheck -primary-file %s %S/Inputs/protocol-inheritance.swift
2
+
3
+ func kitty< Purrs> ( cat: Meow < Purrs > ) {
4
+ cat. pet ( )
5
+ }
You can’t perform that action at this time.
0 commit comments