Skip to content

Commit 11ba9ee

Browse files
authored
Merge pull request #41908 from slavapestov/unbound-generic-protocol-typealias-fix
Sema: Fix structural resolution of protocol typealiases with UnboundGenericType
2 parents 81dc4dc + 6a5d51d commit 11ba9ee

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ Type TypeResolution::resolveTypeInContext(TypeDecl *typeDecl,
433433
if (typeDecl->getDeclContext()->getSelfProtocolDecl()) {
434434
if (isa<AssociatedTypeDecl>(typeDecl) ||
435435
(isa<TypeAliasDecl>(typeDecl) &&
436-
!cast<TypeAliasDecl>(typeDecl)->isGeneric())) {
436+
!cast<TypeAliasDecl>(typeDecl)->isGeneric() &&
437+
!isSpecialized)) {
437438
if (getStage() == TypeResolutionStage::Structural) {
438439
return DependentMemberType::get(selfType, typeDecl->getName());
439440
} else if (auto assocType = dyn_cast<AssociatedTypeDecl>(typeDecl)) {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=on 2>&1 | %FileCheck %s
2+
3+
// CHECK-LABEL: .P@
4+
// CHECK-NEXT: Requirement signature: <Self where Self.[P]X == _A<Int>>
5+
protocol P {
6+
typealias A = _A
7+
typealias B = A<Int>
8+
9+
associatedtype X where X == B
10+
}
11+
12+
struct _A<T> {}

0 commit comments

Comments
 (0)