Skip to content

Commit 34ade3c

Browse files
committed
Also Look Though Class-Bound Protocol Compositions
1 parent 09d540a commit 34ade3c

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

lib/Sema/TypeCheckNameLookup.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,13 @@ static void installSemanticMembersIfNeeded(Type type, DeclNameRef name) {
287287
}
288288
}
289289

290+
if (type->isExistentialType()) {
291+
auto layout = type->getExistentialLayout();
292+
if (auto super = layout.explicitSuperclass) {
293+
type = super;
294+
}
295+
}
296+
290297
if (auto *current = type->getAnyNominal()) {
291298
current->synthesizeSemanticMembersIfNeeded(name.getFullName());
292299
}

test/decl/init/Inputs/inherited-init-multifile-other.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ class A {
22
required init(_ x: Int) {}
33
}
44

5-
class B : A { }
5+
class B : A {}
6+
class C : A {}
7+
8+
protocol P {}

test/decl/init/inherited-init-multifile.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44
func make<Result: B>(ofClass cls: Result.Type) -> Result {
55
return cls.init(1)
66
}
7+
8+
func make(ofClass cls: (C & P).Type) -> C {
9+
return cls.init(1)
10+
}

0 commit comments

Comments
 (0)