Skip to content

Commit 10f0f61

Browse files
authored
Merge pull request #81913 from slavapestov/fix-rdar151479861
AST: Fix crash when type parameter is fixed to an existential
2 parents 9a4ba6f + d8e418a commit 10f0f61

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/AST/TypeSubstitution.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,9 @@ TypeBase::getContextSubstitutions(const DeclContext *dc,
753753
SubstitutionMap TypeBase::getContextSubstitutionMap(
754754
const DeclContext *dc,
755755
GenericEnvironment *genericEnv) {
756-
if (dc == getAnyNominal() && genericEnv == nullptr)
756+
auto *nominal = getAnyNominal();
757+
if (dc == nominal && !isa<ProtocolDecl>(nominal) &&
758+
genericEnv == nullptr)
757759
return getContextSubstitutionMap();
758760

759761
auto genericSig = dc->getGenericSignatureOfContext();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
protocol P1 {
4+
associatedtype Value
5+
}
6+
7+
protocol P2 {
8+
typealias A = Int
9+
}
10+
11+
struct G<T: P1> where T.Value == any Collection, T.Value.Element: P2 {}
12+
// expected-error@-1 {{cannot access associated type 'Element' from 'any Collection'; use a concrete type or generic parameter base instead}}
13+

0 commit comments

Comments
 (0)