Skip to content

Commit 126f024

Browse files
authored
Merge pull request #25410 from DougGregor/local-subs-sr9954
2 parents 12e01d1 + 0216e3b commit 126f024

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,13 @@ Type TypeChecker::applyUnboundGenericArguments(
826826

827827
subs = parentType->getContextSubstitutions(decl->getDeclContext());
828828
skipRequirementsCheck |= parentType->hasTypeVariable();
829+
} else if (auto genericEnv =
830+
decl->getDeclContext()->getGenericEnvironmentOfContext()) {
831+
auto subMap = genericEnv->getForwardingSubstitutionMap();
832+
for (auto gp : subMap.getGenericSignature()->getGenericParams()) {
833+
subs[gp->getCanonicalType()->castTo<GenericTypeParamType>()] =
834+
Type(gp).subst(subMap);
835+
}
829836
}
830837

831838
SourceLoc noteLoc = decl->getLoc();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %target-swift-frontend %s -emit-ir
2+
3+
// SR-9954 / rdar://problem/48223824
4+
// Rejects well-formed that triggered a fallback diagnostic due to a bad
5+
// substitution.
6+
struct GenericThing <Param1, Param2> {
7+
init (closure: (String)->()) {
8+
9+
}
10+
}
11+
12+
struct ThingHolder <Param1> {
13+
func acceptThing <Param2> (thingGenerator: ()->GenericThing<Param1, Param2>) {
14+
15+
}
16+
}
17+
18+
struct A { }
19+
20+
func demo <Param1> (thingHolder: ThingHolder<Param1>) {
21+
typealias Thing <Param2> = GenericThing<Param1, Param2>
22+
thingHolder.acceptThing {
23+
Thing<A> { string in
24+
25+
}
26+
}
27+
}
28+

0 commit comments

Comments
 (0)