SIL: Fix type lowering of 'unowned T' where 'T' is a type parameter

The abstraction pattern's generic signature does not describe
the substituted type, and it may not be present at all.

Fixes https://github.com/swiftlang/swift/issues/79244.
This commit is contained in:
Slava Pestov
2025-02-11 12:38:29 -05:00
parent 7f6a8c6804
commit c1d4589fb7
2 changed files with 35 additions and 13 deletions

View File

@@ -20,4 +20,18 @@ func makeGenericClosureWithNativeClass2<T>(t: T) where T : ClassProtocol, T : Ba
_ = { [unowned t] in _ = t }
}
// CHECK-LABEL: sil private [ossa] @$s4main34makeGenericClosureWithNativeClass21tyx_tAA9BaseClassCRbzAA0I8ProtocolRzlFyycfU_ : $@convention(thin) <T where T : BaseClass, T : ClassProtocol> (@guaranteed @sil_unowned T) -> () {
// CHECK-LABEL: sil private [ossa] @$s4main34makeGenericClosureWithNativeClass21tyx_tAA9BaseClassCRbzAA0I8ProtocolRzlFyycfU_ : $@convention(thin) <T where T : BaseClass, T : ClassProtocol> (@guaranteed @sil_unowned T) -> () {
// https://github.com/swiftlang/swift/issues/79244
struct Wrapper<T: AnyObject> {
unowned var t: T
}
func f1<T: AnyObject>(t: T) {
_ = { Wrapper(t: t) }
}
func f2<T: AnyObject, U: AnyObject>(u: U, tt: Array<Wrapper<T>>) {
_ = tt.map { _ in Wrapper(t: u) }
}