Skip to content

Commit 417a033

Browse files
committed
[Type checker] Ensure that we record archetype anchors.
When we aren't going through proper resolution of an associated type of 'Self', at least record an archetype anchor. Narrow fix for rdar://problem/47605019. (cherry picked from commit 8210f05)
1 parent d2f60e6 commit 417a033

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,8 @@ Type TypeChecker::resolveTypeInContext(
598598
if (resolution.getStage() == TypeResolutionStage::Structural) {
599599
return resolution.resolveSelfAssociatedType(
600600
selfType, foundDC, typeDecl->getName());
601+
} else if (auto assocType = dyn_cast<AssociatedTypeDecl>(typeDecl)) {
602+
typeDecl = assocType->getAssociatedTypeAnchor();
601603
}
602604
}
603605
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s
2+
3+
// Ensure that the superclass's generid argument canonicalizes to
4+
// Sequence.Element.
5+
6+
// CHECK: @"symbolic _____y7ElementSTQzG
7+
8+
public protocol ElementTypeProtocol: RandomAccessCollection {
9+
typealias ElementType = Element
10+
}
11+
extension Array: ElementTypeProtocol {}
12+
13+
private class WrapperBase<T> {}
14+
private final class WrapperDerived<C: ElementTypeProtocol>: WrapperBase<C.ElementType> {
15+
init(base: C) {
16+
let _ = base
17+
}
18+
}

0 commit comments

Comments
 (0)