mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Handle any Error and Never thrown error types during runtime uniquing.
When forming runtime metadata for a function type that has either `any Error` or `Never` as the specified thrown error type, drop the thrown error type and normalize down to (untyped) `throws` or non-throwing, as appropriate.
This commit is contained in:
@@ -526,12 +526,26 @@ enum MyBigError: Error {
|
||||
case epicFail
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.11, *)
|
||||
func getFnTypeWithThrownError<E: Error>(_: E.Type) -> Any.Type {
|
||||
typealias Fn = (Int) throws(E) -> Void
|
||||
return Fn.self
|
||||
}
|
||||
|
||||
if #available(SwiftStdlib 5.11, *) {
|
||||
DemangleToMetadataTests.test("typed throws") {
|
||||
typealias Fn = (Int) throws(MyBigError) -> Void
|
||||
expectEqual("ySi4main10MyBigErrorOYKc", _mangledTypeName(Fn.self)!)
|
||||
print("Looking up the typed throws... \(_typeByName("ySi4main10MyBigErrorOYKc"))")
|
||||
expectEqual(Fn.self, _typeByName("ySi4main10MyBigErrorOYKc")!)
|
||||
|
||||
|
||||
expectEqual(getFnTypeWithThrownError(MyBigError.self), _typeByName("ySi4main10MyBigErrorOYKc")!)
|
||||
|
||||
// throws(any Error) -> throws
|
||||
expectEqual(getFnTypeWithThrownError((any Error).self), _typeByName("ySiKc")!)
|
||||
|
||||
// throws(Never) -> non-throwing
|
||||
expectEqual(getFnTypeWithThrownError(Never.self), _typeByName("ySic")!)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user