Lldb command to print actual type of a generic in runtime

With lldb stopped inside the following function:

func doSomething<T>() -> T {
    // on breakpoint here
}

is it possible to dump type of T? There are no variables nor arguments of type T, it's used purely for type casting inside the function.

You should be able to say expr T.self (or print T.self), at least in debug builds. If that's not working I'd say file a bug.

Is it a feature of Swift, lldb or both?

LLDB's expr command, aliased as print by default, runs an expression and displays the output (also storing it in a variable if it's non-Void). T.self is the normal way to refer to a type as an value, like Int.self, but using the generic parameter T. So, a little of both, I guess?

1 Like
Terms of Service

Privacy Policy

Cookie Policy