Skip to content

Commit be170c8

Browse files
committed
SILGen: Use the right abstraction pattern when loading 'async let' result
The payload is stored maximally-abstracted, so make sure we respect that to avoid a crash when the 'async let' binding has a function type. Fixes rdar://114823719.
1 parent bc7139b commit be170c8

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7023,11 +7023,10 @@ ManagedValue SILGenFunction::emitReadAsyncLetBinding(SILLocation loc,
70237023
assert(visitor.varAddr && "didn't find var in pattern?");
70247024

70257025
// Load and reabstract the value if needed.
7026-
auto genericSig = F.getLoweredFunctionType()->getInvocationGenericSignature();
70277026
auto substVarTy = var->getTypeInContext()->getCanonicalType();
7028-
auto substAbstraction = AbstractionPattern(genericSig, substVarTy);
7029-
return emitLoad(loc, visitor.varAddr, substAbstraction, substVarTy,
7030-
getTypeLowering(substAbstraction, substVarTy),
7027+
return emitLoad(loc, visitor.varAddr,
7028+
AbstractionPattern::getOpaque(), substVarTy,
7029+
getTypeLowering(substVarTy),
70317030
SGFContext(), IsNotTake);
70327031
}
70337032

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend -emit-silgen %s
2+
// REQUIRES: concurrency
3+
4+
public func callee() async -> (() -> ()) {
5+
fatalError()
6+
}
7+
8+
public func caller() async {
9+
async let future = callee()
10+
let result = await future
11+
result()
12+
}

0 commit comments

Comments
 (0)