Skip to content

Commit 7ca7e85

Browse files
authored
Merge pull request #25480 from jckarter/dynamic-self-reabstraction-context
SILGen: Map dynamic self out of context when mangling reabstraction thunk symbols.
2 parents a516de5 + 0c555ed commit 7ca7e85

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/SILGen/SILGenThunk.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,15 @@ getOrCreateReabstractionThunk(CanSILFunctionType thunkType,
311311
->getCanonicalType();
312312
auto toInterfaceType = toType->mapTypeOutOfContext()
313313
->getCanonicalType();
314+
CanType dynamicSelfInterfaceType;
315+
if (dynamicSelfType)
316+
dynamicSelfInterfaceType = dynamicSelfType->mapTypeOutOfContext()
317+
->getCanonicalType();
314318

315319
Mangle::ASTMangler NewMangler;
316320
std::string name = NewMangler.mangleReabstractionThunkHelper(thunkType,
317-
fromInterfaceType, toInterfaceType, dynamicSelfType,
321+
fromInterfaceType, toInterfaceType,
322+
dynamicSelfInterfaceType,
318323
M.getSwiftModule());
319324

320325
auto loc = RegularLocation::getAutoGeneratedLocation();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %target-swift-emit-silgen %s -verify
2+
3+
func foo<T>(_ f: () -> T) -> T { return f() }
4+
5+
class Foo<U> {
6+
func bar() -> Self {
7+
return foo { self }
8+
}
9+
}

0 commit comments

Comments
 (0)