Skip to content

Commit 079fbce

Browse files
authored
Merge pull request #25481 from jckarter/dynamic-self-reabstraction-context-5.1
[5.1] SILGen: Map dynamic self out of context when mangling reabstraction thunk symbols.
2 parents 9d6b213 + 4f2d9c5 commit 079fbce

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
@@ -312,10 +312,15 @@ getOrCreateReabstractionThunk(CanSILFunctionType thunkType,
312312
->getCanonicalType();
313313
auto toInterfaceType = toType->mapTypeOutOfContext()
314314
->getCanonicalType();
315+
CanType dynamicSelfInterfaceType;
316+
if (dynamicSelfType)
317+
dynamicSelfInterfaceType = dynamicSelfType->mapTypeOutOfContext()
318+
->getCanonicalType();
315319

316320
Mangle::ASTMangler NewMangler;
317321
std::string name = NewMangler.mangleReabstractionThunkHelper(thunkType,
318-
fromInterfaceType, toInterfaceType, dynamicSelfType,
322+
fromInterfaceType, toInterfaceType,
323+
dynamicSelfInterfaceType,
319324
M.getSwiftModule());
320325

321326
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)