Skip to content

Commit 8210f05

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.
1 parent dbfc430 commit 8210f05

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
@@ -602,6 +602,8 @@ Type TypeChecker::resolveTypeInContext(
602602
if (resolution.getStage() == TypeResolutionStage::Structural) {
603603
return resolution.resolveSelfAssociatedType(
604604
selfType, foundDC, typeDecl->getName());
605+
} else if (auto assocType = dyn_cast<AssociatedTypeDecl>(typeDecl)) {
606+
typeDecl = assocType->getAssociatedTypeAnchor();
605607
}
606608
}
607609
}
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)