wickwirew / Runtime

A Swift Runtime library for viewing type info, and the dynamic getting and setting of properties.
MIT License
1.08k stars 94 forks source link

Fix bit mask of numberArguments #109

Closed p-x9 closed 9 months ago

p-x9 commented 9 months ago

Hi, I think it is a great library.

I have found that the wrong number of parameters is returned when retrieving FunctionInfo for the following closure.

let t = (@convention(thin) (Int, String) async throws -> String).self

let md = FunctionMetadata(type: t)
let info = md.info()
print(info.numberOfArguments) // -> 131074

It seems to be caused by an incorrect bit mask.

https://github.com/apple/swift/blob/ade2671aee6853e3b76511a9c9a57945676ef237/include/swift/ABI/MetadataValues.h#L1029-L1042

Here is my Swift environment

(Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1))
wickwirew commented 9 months ago

Good catch! Cant believe this hasnt been hit before. Thanks for the fix!

wickwirew commented 9 months ago

@p-x9 btw just pushed 2.2.5 for this fix