Files
swift-mirror/test/SILOptimizer/function-signature-opt.swift
Erik Eckstein b33ddf2df7 FunctionSignatureOptimization: fix wrong error type when creating a thunk
If the specialized function is generic, the optimization derived the wrong error type when creating a thunk for the specialized function.

Fixes a compiler crash
https://github.com/swiftlang/swift/issues/89617
rdar://178484080
2026-06-08 12:28:58 +02:00

18 lines
522 B
Swift

// RUN: %target-swift-frontend -module-name test -emit-sil -O %s | %FileCheck %s
public enum MyError<T>: Swift.Error { case fail }
// Check that function signature opt does not crash when remove the dead argument.
public func foo<T>(_ x: T) throws(MyError<T>) -> UInt8 {
throw .fail
}
// CHECK-LABEL: sil shared @$s4test3fooys5UInt8VxAA7MyErrorOyxGYKlFTf4d_n : $@convention(thin) <T> () -> (UInt8, @error MyError<T>) {
public func run<T>(_ x: T) -> UInt8 {
do {
return try foo(x)
} catch {
return 0
}
}