Skip to content

Commit 015bef1

Browse files
Merge pull request #13416 from aschwaighofer/fix_anyobject_closure_linux
IRGen: The partial application forwarder needs to cast { swift.refcounted* } to swift.refcounted* for AnyObject types on linux
2 parents 9ddd60d + 8610670 commit 015bef1

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/IRGen/GenFunc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ static llvm::Function *emitPartialApplicationForwarder(IRGenModule &IGM,
967967
auto paramInfo = substType->getParameters()[paramI];
968968
auto &ti = IGM.getTypeInfoForLowered(paramInfo.getType());
969969
Explosion param;
970-
param.add(subIGF.Builder.CreateBitCast(rawData, ti.getStorageType()));
970+
param.add(subIGF.coerceValue(rawData, ti.getStorageType(), subIGF.IGM.DataLayout));
971971
bindPolymorphicParameter(subIGF, origType, substType, param, paramI);
972972
(void)param.claimAll();
973973
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s
2+
3+
public class Foo<T> {
4+
}
5+
6+
public func use(_: Any) {}
7+
8+
// Don't crash trying to generate IR.
9+
// CHECK: define{{.*}}swiftcc void @_T028objc_partial_apply_forwarder13createClosureyAA3FooCyxGcyXl1a_xm1ttlF5localL_yAE1x_tlFTA
10+
public func createClosure<T>(a: AnyObject, t: T.Type) -> (Foo<T>) -> () {
11+
func local(x: Foo<T>) {
12+
use(a)
13+
use(x)
14+
}
15+
return local
16+
}
17+

0 commit comments

Comments
 (0)